I tried creating a AWS Lambda Layer for npm package Sharp using this Medium Blog but it is not working for AWS Lambda ARM64 Architecture.
I got this error from lambda function:
"Cannot find module '../build/Release/sharp-linux-arm64v8.node'"
I would like to use this AWS Graviton2 processor only.
Can anyone tell me what is missing in this blog post?
Finally fixed it by re-building the npm package.
Step 1: Create a dir and navigate into it.
mkdir layers
cd layers
Step 2: Create another directory nodejs
mkdir nodejs
cd nodejs
Step 3: Install whatever npm pacakges you need
npm install package-name
Step 4: Re-build installed packages for both x64 and arm64 arch
npm rebuild --platform=linux --arch=x64 package_name
npm rebuild --platform=linux --arch=arm64 package_name
Step 5: Move back to layers directory
cd ..
Step 6: Zip the nodejs directory
zip -r name_whatever_you_want.zip nodejs
All Set!! Now we can upload this as a Lambda Layer