question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module 'sharp' error on AWS lambda

See original GitHub issue

Hi,

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

http://sharp.pixelplumbing.com/en/latest/install/

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:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mbudmcommented, Nov 10, 2018

@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-L521

Another 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.

0reactions
edegiilcommented, Nov 1, 2018

@lovell Of course I included sharp in externals of webpack.config.js This sharp worked very well at original express server (and I used webpack too here)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found