can't resolve "../build/Release/canvas.node" in NX mono repo project
Closed this issue · 1 comments
Quesj commented
Upon deployment of my lambda function to AWS I receive the following error:
[ERROR] Could not resolve "../build/Release/canvas.node"
node_modules/.pnpm/canvas@2.11.2/node_modules/canvas/lib/bindings.js:3:25:
3 │ const bindings = require('../build/Release/canvas.node')
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am currently working on a MacBook Ventura 13.4 in a NX Mono repo project. Installation with pnpm succeeded without trouble.
full logs:
pnpm nx deploy outlook-notification-service --all
✔ 4/4 dependent project tasks succeeded [4 read from cache]
Hint: you can run the command with --verbose to see the full dependent project outputs
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
> nx run outlook-notification-service:deploy --all
OptionsParsedExecutorInterface {"all":true,"parseArgs":{"all":true},"sourceRoot":"apps/outlook-notification-service/src","root":"apps/outlook-notification-service"}
nodeCommandWithRelativePath node /Users/jopluysterburg/nn-si-apps/node_modules/aws-cdk/bin/cdk.js deploy
Executing command: node /Users/jopluysterburg/nn-si-apps/node_modules/aws-cdk/bin/cdk.js deploy --all true
Bundling asset jopluysterburg-outlook-notification-service-delta-query/run-cycle-lambda/Code/Stage...
...8fd9b885fff3a4aea42171ec022a7be290526cb840f39d5fde19b45/index.js 1.8mb ⚠️
⚡ Done in 320ms
Bundling asset jopluysterburg-outlook-notification-service-delta-query/restart-cycle-lambda/Code/Stage...
...d50faf401aaba372e1b18435da90c9514d6f56fb5fda6d330d5c458/index.js 1.8mb ⚠️
⚡ Done in 62ms
Bundling asset jopluysterburg-outlook-notification-service-moev-worker/moev-worker/Code/Stage...
✘ [ERROR] Could not resolve "../build/Release/canvas.node"
node_modules/.pnpm/canvas@2.11.2/node_modules/canvas/lib/bindings.js:3:25:
3 │ const bindings = require('../build/Release/canvas.node')
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error
/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2
`),localBundling=options.local?.tryBundle(bundleDir,options),!localBundling){const assetStagingOptions={sourcePath:this.sourcePath,bundleDir,...options};switch(options.bundlingFileAccess){case bundling_1.BundlingFileAccess.VOLUME_COPY:new asset_staging_1.AssetBundlingVolumeCopy(assetStagingOptions).run();break;case bundling_1.BundlingFileAccess.BIND_MOUNT:default:new asset_staging_1.AssetBundlingBindMount(assetStagingOptions).run();break}}}catch(err){const bundleErrorDir=bundleDir+"-error";throw fs.existsSync(bundleErrorDir)&&fs.removeSync(bundleErrorDir),fs.renameSync(bundleDir,bundleErrorDir),new Error(`Failed to bundle asset ${this.node.path}, bundle output is located at ${bundleErrorDir}: ${err}`)}if(fs_1.FileSystem.isEmpty(bundleDir)){const outputDir=localBundling?bundleDir:AssetStaging.BUNDLING_OUTPUT_DIR;throw new Error(`Bundling did not produce any output. Check that content is written to ${outputDir}.`)}}calculateHash(hashType,bundling,outputDir){if(hashType==assets_1.AssetHashType.CUSTOM||hashType==assets_1.AssetHashType.SOURCE&&bundling){const hash=crypto.createHash("sha256");return hash.update(this.customSourceFingerprint??fs_1.FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions)),bundling&&hash.update(JSON.stringify(bundling)),hash.digest("hex")}switch(hashType){case assets_1.AssetHashType.SOURCE:return fs_1.FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions);case assets_1.AssetHashType.BUNDLE:case assets_1.AssetHashType.OUTPUT:if(!outputDir)throw new Error(`Cannot use \`${hashType}\` hash type when \`bundling\` is not specified.`);return fs_1.FileSystem.fingerprint(outputDir,this.fingerprintOptions);default:throw new Error("Unknown asset hash type.")}}}_a=JSII_RTTI_SYMBOL_1,AssetStaging[_a]={fqn:"aws-cdk-lib.AssetStaging",version:"2.86.0"},AssetStaging.BUNDLING_INPUT_DIR="/asset-input",AssetStaging.BUNDLING_OUTPUT_DIR="/asset-output",AssetStaging.assetCache=new cache_1.Cache,exports.AssetStaging=AssetStaging;function renderAssetFilename(assetHash,extension=""){return`asset.${assetHash}${extension}`}function determineHashType(assetHashType,customSourceFingerprint){const hashType=customSourceFingerprint?assetHashType??assets_1.AssetHashType.CUSTOM:assetHashType??assets_1.AssetHashType.SOURCE;if(customSourceFingerprint&&hashType!==assets_1.AssetHashType.CUSTOM)throw new Error(`Cannot specify \`${assetHashType}\` for \`assetHashType\` when \`assetHash\` is specified. Use \`CUSTOM\` or leave \`undefined\`.`);if(hashType===assets_1.AssetHashType.CUSTOM&&!customSourceFingerprint)throw new Error("`assetHash` must be specified when `assetHashType` is set to `AssetHashType.CUSTOM`.");return hashType}function calculateCacheKey(props){return crypto.createHash("sha256").update(JSON.stringify(sortObject(props))).digest("hex")}function sortObject(object){if(typeof object!="object"||object instanceof Array)return object;const ret={};for(const key of Object.keys(object).sort())ret[key]=sortObject(object[key]);return ret}function singleArchiveFile(directory){if(!fs.existsSync(directory))throw new Error(`Directory ${directory} does not exist.`);if(!fs.statSync(directory).isDirectory())throw new Error(`${directory} is not a directory.`);const content=fs.readdirSync(directory);if(content.length===1){const file=path.join(directory,content[0]),extension=getExtension(content[0]).toLowerCase();if(fs.statSync(file).isFile()&&ARCHIVE_EXTENSIONS.includes(extension))return file}}function determineBundledAsset(bundleDir,outputType){const archiveFile=singleArchiveFile(bundleDir);switch(outputType===bundling_1.BundlingOutput.AUTO_DISCOVER&&(outputType=archiveFile?bundling_1.BundlingOutput.ARCHIVED:bundling_1.BundlingOutput.NOT_ARCHIVED),outputType){case bundling_1.BundlingOutput.NOT_ARCHIVED:return{path:bundleDir,packaging:assets_1.FileAssetPackaging.ZIP_DIRECTORY};case bundling_1.BundlingOutput.ARCHIVED:if(!archiveFile)throw new Error("Bundling output directory is expected to include only a single archive file when `output` is set to `ARCHIVED`");return{path:archiveFile,packaging:assets_1.FileAssetPackaging.FILE,extension:getExtension(archiveFile)}}}function getExtension(source){for(const ext of ARCHIVE_EXTENSIONS)if(source.toLowerCase().endsWith(ext))return ext;return path.extname(source)}
^
Error: Failed to bundle asset jopluysterburg-outlook-notification-service-moev-worker/moev-worker/Code/Stage, bundle output is located at /Users/jopluysterburg/nn-si-apps/apps/outlook-notification-service/cdk.out/bundling-temp-d584e2c42df1368879da8c18f61404b80a3bf918e8d5566b694c054423a0bcef-error: Error: bash -c pnpm exec -- esbuild --bundle "/Users/jopluysterburg/nn-si-apps/apps/outlook-notification-service/src/lambda/moev-worker.ts" --target=node18 --platform=node --outfile="/Users/jopluysterburg/nn-si-apps/apps/outlook-notification-service/cdk.out/bundling-temp-d584e2c42df1368879da8c18f61404b80a3bf918e8d5566b694c054423a0bcef/index.js" --external:@aws-sdk/* run in directory /Users/jopluysterburg/nn-si-apps exited with status 1
at AssetStaging.bundle (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:603)
at AssetStaging.stageByBundling (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:4544)
at stageThisAsset (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2005)
at Cache.obtain (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
at new AssetStaging (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2400)
at new Asset (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:736)
at AssetCode.bind (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4628)
at new Function (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:7479)
at new NodejsFunction (/Users/jopluysterburg/nn-si-apps/node_modules/.pnpm/aws-cdk-lib@2.86.0_constructs@10.1.164/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1174)
at new WorkerStack (/Users/jopluysterburg/nn-si-apps/apps/outlook-notification-service/lib/worker-stack.ts:62:5)
npm notice
npm notice New major version of npm available! 8.19.3 -> 10.0.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.0.0>
npm notice Run `npm install -g npm@10.0.0` to update!
npm notice
Subprocess exited with error 1
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
> NX Ran target deploy for project outlook-notification-service and 4 task(s) they depend on (18s)
With additional flags:
--all=true
✖ 1/5 failed
✔ 4/5 succeeded [4 read from cache]
ffalt commented
Hi, sorry, I have no clue. node-canvas is a dependency, please have a look if you find a releated issue there https://github.com/Automattic/node-canvas/issues
I'm not using pnpm, so I don't have any experience what could have gone wrong.