sharp: sharp is not working ( install ) in aws lambda ( serverless-webpack )
[I used]
1. serverless framework ( aws lambda, aws-nodejs-typescript template )
2. node version 12.14.1
3. sharp version 0.25.2 ( I did test 0.25.0 ~ 0.25.3 )
I want to resize my lambda zip size.
So I did install serverless-webpack plugins and bundle my lambda.
Before bundled by webpack, only transpile typescript to javascript and deploy using serverless and works well.
But, lambda bundled by serverless-webpack is not working.
[Error message] darwin-x64’ binaries cannot be used on the ‘linux-x64’ platform. Please remove the ‘node_modules/sharp/vendor’
I don’t know how to do.
I did check node_modules/sharp/vendor and saw linux-64 target.
but lambda is darwin-x64 logged.
I don’t want to use lambda layer.
How to do?
I did
- Delete node_modules and package-lock.json and install dependencies ( also installed sharp )
- Delete node_modules/sharp and install sharp ( lambda environment - linux, x64, node version )
- Set serverless-webpack configuration in serverless : packagerOptions ( scrips ) - rebuild sharp lambda enviroment But, lambda is not working
upload and delete lambda work well and resized zip size!!
but get ( resize image ) lambda is not.
Please help me.
Thank you
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 19 (4 by maintainers)
I fixed this issue by forcing the webpack to run the scripts I am using
serverless-bundleSo the solution to fix it, it was the following …https://sharp.pixelplumbing.com/install#aws-lambda https://www.npmjs.com/package/serverless-bundle
Thank you…
I wrote that post…
For those using esbuild plugin
Did you see the following?
https://sharp.pixelplumbing.com/install#aws-lambda
https://github.com/serverless-heaven/serverless-webpack#node-modules--externals
I did change module ( sharp to jimp )
Jimp is working. ( zero native dependency )
But, Jimp slower than sharp…
Jimp : https://www.npmjs.com/package/jimp
sharp and jimp performance : https://sharp.pixelplumbing.com/performance
Cross-posted at https://stackoverflow.com/questions/62039078/error-darwin-x64-binaries-cannot-be-used-on-the-linux-x64-platform-aws-lamb