lambda-layer-sharp icon indicating copy to clipboard operation
lambda-layer-sharp copied to clipboard

Cannot find module '../build/Release/sharp-linux-x64.node' error with the layer Error

Open arunwij opened this issue 3 years ago • 3 comments

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,

  1. Download the 0.29.3 version from https://github.com/Umkus/lambda-layer-sharp/releases page
  2. Upload the zip file as a Lambda layer
  3. 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" }

arunwij avatar Feb 22 '22 18:02 arunwij

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.

jean-jacket avatar Feb 23 '22 22:02 jean-jacket

I'm having the same issue, yes the sharp (and the '../build/Release/sharp-linux-x64.node') exists in the zip file.

markhker avatar Jul 20 '22 15:07 markhker

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.

jean-jacket avatar Jul 20 '22 15:07 jean-jacket

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.

Umkus avatar Feb 26 '23 20:02 Umkus