aws lambda with typescript is occured error when bundle by webpack.
Before bundle webpack, I did "npm i --arch=x64 --platform=linux --target=12.14.1 sharp" and labmda is working properly.
But, lambda upload zip size is more and more larger.
so, I want to resize lambda upload zip size using serverless-webpack.
Image lambda is working well except using sharp module.
I don't know 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 properly.
and I looked many informations.
[lambda linux env]
Error running Sharp inside AWS Lambda function: darwin-x64' binaries cannot be used on the 'linux-x64' platform
[Serverless-webpack]
https://github.com/serverless-heaven/serverless-webpack/issues/396
Thank you!
[Edit]
My local env : Mac
production env : linux
Maybe, I think that npm command with "--platform" is not working in mac.
Additionally, I solved this problem using aws codebuild.
I posted answer.
But, It is not working in my local [ Mac ]