Cannot find module 'sharp' error on AWS lambda
See original GitHub issueHi,
Currently I am mounting express server to AWS lambda.
But lambda keep throwing error
"Cannot find module 'sharp'"
sharp
worked very well at express server but not here lambda
I tried sharp
version 0.20.1 nodejs 8.10
I tried these on
rm -rf node_modules/sharp
docker run -v "$PWD":/var/task lambci/lambda:build-nodejs8.10 npm install
but not working
It would be really appreciated to help me to solve this error
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Something went wrong installing the \"sharp\" on aws Lambda
To fix it on MAC, try this solution: npm install --platform=linux --arch=x64 sharp. It worked for me.
Read more >Resolve the "Unable to import module" error for Lambda code ...
I receive the "Unable to import module" error when I try to run my AWS Lambda code in Node.js. Short description. You typically...
Read more >AWS Lambda error on build Node with Sharp Library
I have a problem to build my lambda handler. I'm trying to use sharp library to do an image resize on S3. My...
Read more >How to use AWS Lambda Layers with SAM - BlowStack
If you don't mark layer dependencies as external the following error will pop up during building. Could not resolve "sharp" thumbnail-post-cover ...
Read more >claudiajs/claudia - Gitter
Hey @rcoundon, this is an issue with AWS Lambda, not Claudia, but let me try to explain. Some of the node modules (such...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wingtree - here are some things to check:
You mentioned you are using
serverless-webpack
so using serverless framework to deploy? If so the best option is to explicitly tell serverless-webpack plugin what modules you want to include in your bundle (this keeps your zip to the smallest size possible, for faster uploading). Here’s my config for example: https://github.com/mbudm/fotopia-serverless/blob/master/serverless.yml#L515-L521Another thing that just threw me was that with the move to 10.x in LTS my CI build was now packaging sharp and my other modules in a different node version to the lambda environment. This produced an error like https://github.com/lovell/sharp/issues/1197. Changing my travis-ci build config to explicitly use node v8.10.0 fixed this.
May not be your issues but definitely things to watch out for.
@lovell Of course I included
sharp
inexternals
ofwebpack.config.js
Thissharp
worked very well at original express server (and I usedwebpack
too here)