AWS Lambda Fails On Require
See original GitHub issueHi,
I apologize in advance if I’m missing something simple, but I’ve read through a bunch of the issues that were similar to this one, and the solutions did not fix my issue. I am using sharp in an AWS Lambda, which I am packing up on a Mac. Whenever the Lambda runs, I get this error when the Lambda attempts to require(‘sharp’)
Something went wrong installing the "sharp" module
libvips-cpp.so.42: cannot open shared object file: No such file or directory
- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues
I have tried running the npm install with all the options mentioned in the installation guide, and using the docker run command. Both result in this same error message. I am able to use Sharp locally on my Mac with a docker run command of docker run -v "$PWD":/var/task lambci/lambda:build-nodejs10.x node index2.js where index2.js is just a little test file. I am on macOS 10.14.6 and using node10.x on the Lambda.
Did you see the documentation relating to installation?
Yes, I have followed the instructions for setting up sharp for a Lambda function with the npm install and zip occuring on a Mac
Have you ensured the platform and version of Node.js used for npm install is the same as the platform and version of Node.js used at runtime?
Yes, I tried both options available in the installation instructions
If you’re (mis)using sudo npm install have you tried with the sudo npm install --unsafe-perm flag?
What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?
I don’t see any errors on the npm install
What is the output of running npx envinfo --binaries --languages --system --utilities?
Would this be useful to run in the AWS Lambda?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)

Top Related StackOverflow Question
So I finally got to the bottom of it, and it turns out it was unrelated to your library. So I apologize for using up your time, and appreciate you helping me get to the bottom of it. I was using terraform to zip the Lambda contents, but the
archive_fileprovider from terraform has an old, nasty bug where it does not handle symlinks correctly.https://github.com/terraform-providers/terraform-provider-archive/issues/6#issuecomment-321376294
For anyone in the future who runs into this as a problem, I used the above to workaround terraform’s inability to zip files with symlinks
Glad to hear you got it working.
If you’re able, I’m sure users of terraform-provider-archive would welcome a PR to either fix this problem or a PR to clearly document this limitation in the currently-blank “Fill in for each provider” section of its README.