Hi,
I was using sharp for an AWS Lambda function (v0.18.0) and it was working very well. I want to update to the last version (v0.21), however, I'm now having an issue:
It looks like there is a problem with libvips:
"stackTrace": [
"Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:9:22)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object.<anonymous> (/var/task/node_modules/sharp/lib/index.js:3:15)"
]
CloudWatch logs:
module initialization error: Error
at Object.hasVendoredLibvips (/var/task/node_modules/sharp/lib/libvips.js:61:13)
at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:9:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/task/node_modules/sharp/lib/index.js:3:15)
I don't really understand your documentation
Do I need to install Docker, create a linux container and then do npm install?
Hello, AWS Lambda uses 64-bit Linux and you'll need to ensure npm install is run on the same platform to populate node_modules with the correct files.
The Docker command shown at http://sharp.pixelplumbing.com/en/stable/install/#aws-lambda allows you to run npm install inside a Linux container that closely matches the AWS Lambda runtime.
I couldn't run the cmd in your doc so I pulled ubuntu image (Docker), install npm and run npm install. All good now. Thank you for your reply though, appreciate it.
Commit dcd6830 adds a Docker-less method to the docs.
rm -rf node_modules/sharp
npm install --arch=x64 --platform=linux --target=8.10.0 sharp
http://sharp.pixelplumbing.com/en/latest/install/#aws-lambda
How does one do this with Yarn?
I've tried yarn add --arch=x64 --platform=linux --target=10.16.0 sharp but nothing is being installed into node_modules
you can try this:
download the latest release binaries from https://github.com/lovell/sharp/releases and manually copy sharp.node into node_modules/sharp/build/Release, then do serverless deploy
Most helpful comment
Commit dcd6830 adds a Docker-less method to the docs.
http://sharp.pixelplumbing.com/en/latest/install/#aws-lambda