lambda-layer-sharp
lambda-layer-sharp copied to clipboard
Cannot find module '../build/Release/sharp-linux-x64.node' error with the layer Error
Hello there,
Thank you for creating this layer. I had a hard time figuring out Sharp to work with Lambda. I tried your prebuilt layer.
This is what I tried,
- Download the 0.29.3 version from https://github.com/Umkus/lambda-layer-sharp/releases page
- Upload the zip file as a Lambda layer
- Added the layer to Lambda function (nodejs 12.x & x86_64 Architecture)
When I run the function I get the below error. I am not sure what I am doing wrong here.
{ "errorType": "Error", "errorMessage": "\nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-linux-x64.node'\nRequire stack:\n- /var/task/src/files/s3/compress.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js\n\nPossible solutions:\n- Install with the --verbose flag and look for errors: \"npm install --ignore-scripts=false --verbose sharp\"\n- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install" }
Does sharp exist in the node_modules deployed in the zip file? That may be causing the issue. Should work if you delete it then deploy again.
I'm having the same issue, yes the sharp (and the '../build/Release/sharp-linux-x64.node') exists in the zip file.
Sorry I don't think I was clear in the previous message. The issue is caused by the existence of the sharp folder in the deployed function's node_modules folder. So if you delete the sharp folder in node_modules before zipping it should work.
I just tried with latest zip from the releases page and it seems to work fine for me.
I just made a number of changes to the project, you should now have more luck get it to work. Just tested by downloading the zip from releases and importing it as a layer supporting all supported runtimes (node14+) and architectures. Tested with lambda on node18 for both arm and x86.