Error when using Sharp module in AWS lambda - node.js

I'm deploying a lambda on AWS that uses the Sharp module to resize an image.
Despite using linux to deploy the following error happens:
"Something went wrong installing the sharp module,
Module parse failed: Unexpected character 'u007f' (1: 0),
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders,
(Source code omitted for this binary file), "
In my research I saw that the problem was associated with the OS. That it was necessary to install sharp using "npm install --arch = x64 --platform = linux sharp".
However, the problem continues to happen.
Even using linux x84_64 this problem happens, does anyone know what it could be?

Related

npm sqlite3 package does not work when installing on linux / invalid ELF header

I am trying to get my development environment up and running for my Shopify app and it has been awhile. Shopify updates so rapidly I am forced to either reintegrate my code with a new Shopify app instance or try to get the original to work. Unfortunately, I cannot run my current application because sqlite3 will not work / install. I have tried installing from the source as recommended by the NPM documentation. I keep getting this error:
web/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node: invalid ELF header
Apparently this has to do with the binary not matching my system, which it is supposed to after running "npm install -g sqlite3 --build-from-source". Is there a way to install a specific build so that I can simply test all the linux builds to see if I can find a potential match or see if anything works?

Got error on installation of strapi. something went wrong installing the "sharp" module. How to fix it

sharp module is present in node_module folder but why it's showing error . I don't know what's the reason behind.Even I install sharp.but still getting error.If anyone know how to fix sharp module ?. In addition. when I try to install with yarn than got something else error.
C:\Users\4' is not recognized as an internal or external command,
operable program or batch file.
Error :
Could not load js config file D:\Mohsin-Work-Space\Strapi Backend Practice Session\project_strapi23\node_modules#strapi\plugin-upload\strapi-server.js:
Something went wrong installing the "sharp" module
The specified module could not be found.
\?\D:\Mohsin-Work-Space\Strapi Backend Practice Session\project_strapi23\node_modules#strapi\plugin-upload\node_modules\sharp\build\Release\sharp-win32-x64.node
I also run into this problem during my installation, and how I managed to fix it was to run the installation command as administrator and everything worked.

I get bcrypt error after deployed my nodejs/expressjs app to AWS lambda

I am trying to make my express.js app works on AWS Lambda. The deployment (using serverless framework completes successfully, however the app returns a 500 internal error when I test my requests. My logs shows me this error :
/var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header.
I've tried to replace bcrypt with bcryptjs but the problem persists.
Also, in my serverless.yml, I've added the following line to force lambda to install bcrypt by itself, but apparently it didn't make the trick :
package:
exclude:
- node_modules/**
Any suggestion ?
First, please include node modules. AWS won't install anything into the lambda node env besides the aws-sdk.
Secondly, you're seeing this error because your likely developing on a mac OS machine, so the bycrypt binary from your machine is ending up getting uploaded to lambda.
Please double check that when you tried bcryptjs, you fully removed bcrypt from your project dependencies.

How to add ICU data to Node.js in AWS Lambda?

My question is similar to an existing one, but I'm using webpack and thus don't even have a "node_modules" directory.
I've still tried the following environment variable settings without success:
NODE_ICU_DATA: 'node_modules/full-icu'
NODE_ICU_DATA: '/var/task/node_modules/full-icu/icudt58l.dat'
NODE_ICU_DATA: '/var/task/node_modules/full-icu/icudt60l.dat'
All without success, the lambdas simply refuse to start and a log message is show in CloudWatch:
/var/lang/bin/node: could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir parameters)
I found very little about this problem on Google, which seems curious given that it should concern so many that are building internal apps on AWS lambda.
Make sure you're deploying the correct .dat file version into the directory defined by NODE_ICU_DATA. In my case, the correct file was icudt62l.dat when using the runtime nodejs10.x for my lambdas. If you're not deploying node_modules as part of your lambda, you can grab the correct .dat file and deploy that.
I ran into the same error message when upgrading the runtime version of some old lambdas from nodejs6.10 to nodejs10.x. In my case, the file icudt58l.dat (compatible with nodejs6.10) was deployed into the project root, and the value of NODE_ICU_DATA was . (i.e. the directory where my lambda executes, equivalent to /var/task/).
To get a compatible .dat file, I re-installed the full-icu package using the node version used by the lambdas:
npx -p node#10.x npm i full-icu
It's important that the version of the .dat file is correct for the runtime version your lambdas are using. Initially, I made the mistake of just running npm i full-icu using node version 10.0 but this installed the wrong version of the .dat file and I just got the same error message again.
Finally, I copied the file node_modules/full-icu/icudt62l.dat into the project root and deleted the old icudt58l.dat so that it ends up in /var/task/ where the lambda can find it when NODE_ICU_DATA=..

How to setup gm (GraphicsMagick) on aws lambda?

I've been trying to get node gm to work on aws lambda.
I installed the imagemagick and graphicmagick libraries on an EC2 instance created from a lambda execution environment. I pointed the appPath to these libraries from gm.
I still get the following error -
Error: Could not execute GraphicsMagick/ImageMagick: /var/task/graphicsmagick/bin/identify "-ping" "-format" "%wx%h" "./resultant-file.jpg" this most likely means the gm/convert binaries can't be found
Can anyone suggest me the right folder structure for such an app or any pointers as to where I'm going wrong?

Resources