Closed aidan-ayala closed 2 years ago
Hello
We're getting this error when trying to use the layer with the serverless framework.
error
{ "errorType": "Error", "errorMessage": "/var/task/node_modules/node-canvas/build/Release/canvas.node: invalid ELF header", "stack": [ "Error: /var/task/node_modules/node-canvas/build/Release/canvas.node: invalid ELF header", " at Object.Module._extensions..node (internal/modules/cjs/loader.js:1131:18)", " at Module.load (internal/modules/cjs/loader.js:937:32)", " at Function.Module._load (internal/modules/cjs/loader.js:778:12)", " at Module.require (internal/modules/cjs/loader.js:961:19)", " at require (internal/modules/cjs/helpers.js:92:18)", " at Object.<anonymous> (/var/task/node_modules/node-canvas/lib/bindings.js:3:18)", " at Module._compile (internal/modules/cjs/loader.js:1072:14)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)", " at Module.load (internal/modules/cjs/loader.js:937:32)", " at Function.Module._load (internal/modules/cjs/loader.js:778:12)" ] }
package.json
{ "name": "app", "version": "1.0.0", "description": "app", "main": "serverless.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "engines": { "node": ">=14.15.0" }, "dependencies": { "@middy/core": "^1.5.2", "@middy/http-json-body-parser": "^1.5.2", "merge-images": "^2.0.0", "node-canvas": "^2.7.0", "source-map-support": "^0.5.19" }, "devDependencies": { "@serverless/typescript": "^2.23.0", "@types/aws-lambda": "^8.10.71", "@types/node": "^14.14.25", "json-schema-to-ts": "^1.5.0", "serverless": "^2.23.0", "serverless-offline": "^8.2.0", "serverless-webpack": "^5.3.5", "ts-loader": "^8.0.15", "ts-node": "^9.1.1", "tsconfig-paths": "^3.9.0", "tsconfig-paths-webpack-plugin": "^3.3.0", "typescript": "^4.1.3", "webpack": "^5.20.2", "webpack-node-externals": "^2.5.2" }, "author": "The serverless webpack authors (https://github.com/elastic-coders/serverless-webpack)", "license": "MIT" }
Haven't seen anyone else posting issues about this. Any idea on where to start?
Hi @aidan-ayala,
It looks when specifying "node-canvas": "^2.7.0", it actually loads node-canvas from NPM repo, would you please try to replace the loaded node-canvas folder manually using the one in your AWS Lambda console, you may download the packages from the Layer section of the AWS Lambda console.
In case you need any further assistance, please let me know. Thank you.
Regards, Charoite
Hello
We're getting this error when trying to use the layer with the serverless framework.
error
package.json
Haven't seen anyone else posting issues about this. Any idea on where to start?