I am trying to resize my images with the help of Aws lambda and getting error
and i am following this article
https://aws.amazon.com/blogs/compute/resize-images-on-the-fly-with-amazon-s3-aws-lambda-and-amazon-api-gateway/
{
"errorType": "Error",
"errorMessage": "The module '/var/task/node_modules/sharp/build/Release/sharp.node'\nwas compiled against a different Node.js version using\nNODE_MODULE_VERSION 48. This version of Node.js requires\nNODE_MODULE_VERSION 64. Please try re-compiling or re-installing\nthe module (for instance, using `npm rebuild` or `npm install`).",
"trace": [
"Error: The module '/var/task/node_modules/sharp/build/Release/sharp.node'",
"was compiled against a different Node.js version using",
"NODE_MODULE_VERSION 48. This version of Node.js requires",
"NODE_MODULE_VERSION 64. Please try re-compiling or re-installing",
"the module (for instance, using `npm rebuild` or `npm install`).",
" at Object.Module._extensions..node (internal/modules/cjs/loader.js:730:18)",
" at Module.load (internal/modules/cjs/loader.js:600:32)",
" at tryModuleLoad (internal/modules/cjs/loader.js:539:12)",
" at Function.Module._load (internal/modules/cjs/loader.js:531:3)",
" at Module.require (internal/modules/cjs/loader.js:637:17)",
" at require (internal/modules/cjs/helpers.js:22:18)",
" at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:8:15)",
" at Module._compile (internal/modules/cjs/loader.js:701:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)",
" at Module.load (internal/modules/cjs/loader.js:600:32)"
]
}
Steps to fix it: -
Download your project(function) form AWS Lambda using Action->Export function and unzip it.
Install Latest version of node in your local system(say node 8.10.0). You can see i already have 8.10.0.
Go to your unzipped project folder via terminal and type
npm rebuild
After this again zip this project and uplaod it on AWS Lambda and select the node runtime one you updated with (suppose it is node 8.10.0 then select runtime in aws lambda function runtime as node 8.10x).
Hope it helps.
Thanks
Related
I am trying to upgrade the nodeJS version of my lambda functions from v12 to v16. The functions have been deployed via serverless with the application contained in a docker image.
My function is using the GRPC library and the below error pop up when I run the function after upgrade.
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Failed to load gRPC binary module because it was not installed for the current system\nExpected directory: node-v83-linux-x64-glibc\nFound: [node-v72-linux-x64-glibc]\nThis problem can often be fixed by running \"npm rebuild\" on the current system\nOriginal error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node'\nRequire stack:\n- /var/task/node_modules/grpc/src/grpc_extension.js\n- /var/task/node_modules/grpc/src/client_interceptors.js\n- /var/task/node_modules/grpc/src/client.js\n- /var/task/node_modules/grpc/index.js\n- /var/task/src/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Failed to load gRPC binary module because it was not installed for the current system",
"Expected directory: node-v83-linux-x64-glibc",
"Found: [node-v72-linux-x64-glibc]",
"This problem can often be fixed by running \"npm rebuild\" on the current system",
"Original error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node'",
"Require stack:",
"- /var/task/node_modules/grpc/src/grpc_extension.js",
"- /var/task/node_modules/grpc/src/client_interceptors.js",
"- /var/task/node_modules/grpc/src/client.js",
"- /var/task/node_modules/grpc/index.js",
"- /var/task/src/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/Runtime.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:225:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:300:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:34)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)",
" at internal/main/run_main_module.js:17:47"
]
}
I am just updating the run time in my serverless
runtime: nodejs12.x // changing it to 14 or 16 here
and parallely also changing the version in my Docker
FROM node:12 as builder # changed to 14 or 16 as per serverless runtime
# ensure installation
RUN node -v; npm -v
#### Few COPY Command on package.json ###
RUN yarn install --frozen-lockfile
FROM builder as base
The error is also encountered when I changed the version via runtime setting in Lambda.
AWS Lambda Runtime change screen
Few below steps were tried :
Tried upgrading the version via serverless and Dockerfile.
Changed runtime setting from AWS.
The error indicates that the grpc package was installed using a different version of Node than the one that is loading it. You can probably fix this by rebuilding the docker image from scratch. However, the grpc package is deprecated, and does not work on any version of Node greater than 14. The replacement package is #grpc/grpc-js.
This is the error shown while running.
On bcrypt's GitHub wiki, they say that it is a native module for node-js and that it requires a compiler and build dependencies in order to build.
What am I doing wrong, can someone please help me
{
"errorType": "Error",
"errorMessage": "/var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header",
"stack": [
"Error: /var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header",
" at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Module.require (internal/modules/cjs/loader.js:887:19)",
" at require (internal/modules/cjs/helpers.js:74:18)",
" at Object.<anonymous> (/var/task/node_modules/bcrypt/bcrypt.js6️⃣16)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)"
]
}
I was having the same problem,solved it by using **bcryptjs** (npm i bcryptjs) instead of bcrypt package.
It appears bcrypt fails on lambda because it uses node-gyp to build and install - not sure though will have to work though it.
Until then, bcryptjs works.
I get the following error when I try to set up "Hello World" test suite into my project by running: "npx wdio config". I followed the instructions on the https://webdriver.io/docs/gettingstarted and still not able to get it to work.
Can someone help me with resolving this:
WDIO Configuration Helper
? Where is your automation backend located? (Use arrow keys)
❯ On my local machine
In the cloud using Experitest
In the cloud using Sauce Labs
In the cloud using Browserstack or Testingbot or LambdaTest or a different service
I have my own Selenium cloud (node:2831) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined
at Object.run (/Users/gustavosuarez/web/mo-appium-wdio-jasmine/node_modules/#wdio/cli/build/index.js:67:19)
at Object.<anonymous> (/Users/gustavosuarez/web/mo-appium-wdio-jasmine/node_modules/#wdio/cli/bin/wdio.js:11:21)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Seems to be a problem with the latest version of the #wdio/cli dependency. I solved the problem by using an older version and it works now ("#wdio/cli": "7.3.1"). Just add that dependency to your package.json and run yarn or npm install again, then npx wdio config and it should work.
My Lambda function is running on Node JS 10.x. Tried requiring the soap npm module but it fails with the following error.
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'soap'",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'soap'",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:45:30)",
" at Module._compile (internal/modules/cjs/loader.js:778:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
" at Module.load (internal/modules/cjs/loader.js:653:32)",
" at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
" at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
" at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)",
" at startup (internal/bootstrap/node.js:283:19)"
]
}
Tried looking in several threads but no luck. The file name is index.js and the handler name is index.handler if that information helps.
The issue was due to the folder structure and dependencies set up. Since 'soap' module is an additional package which is out of the libraries in the AWS SDK for JavaScript. I install it locally with npm and included it in the deployment package. Then updated the Lambda function using AWS SDK.
Refer this - https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#nodejs-package-dependencies
I am trying to deploy a reactjs app to an elastic beanstalk instance and seem to be encountering several issues.
1) I am receiving this error in the health section for elastic beanstalk:
/opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
node-sass#4.9.3 install /tmp/deployment/application/node_modules/node-sass
node scripts/install.js
Unable to save binary
/tmp/deployment/application/node_modules/node-sass/vendor/linux-x64-57
: { Error: EACCES: permission denied, mkdir
'/tmp/deployment/application/node_modules/node-sass/vendor' at
Object.fs.mkdirSync (fs.js:885:18) at sync
(/tmp/deployment/application/node_modules/mkdirp/index.js:71:13) at
Function.sync
(/tmp/deployment/application/node_modules/mkdirp/index.js:77:24) at
checkAndDownloadBinary
(/tmp/deployment/application/node_modules/node-sass/scripts/install.js:114:11)
at Object.
(/tmp/deployment/application/node_modules/node-sass/scripts/install.js:157:1)
at Module._compile (module.js:652:30) at Object.Module._extensions..js
(module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad
(module.js:505:12) at Function.Module._load (module.js:497:3) errno:
-13, code: 'EACCES', syscall: 'mkdir', path: '/tmp/deployment/application/node_modules/node-sass/vendor' }
2) At the same time it appears as if node and npm are claiming all of the resources for my ec2 instance and this seems to continue even after the deployment fails.
What could be the cause of this failure? The other packages seems to be deploying as they are in the node_modules folder? Additionally, why would node take up resources in this fashion?
The reactjs app is using webpack and node-sass ^4.9.3 and node version 8.11.3 which works on my local environment.
Update: .npmrc solved the permission issue. I am still having a problem with the cpu being 100%. In the build script, the code is not getting past this line, I adding console.log lines at various points in the code:
let compiler = webpack(config);
After this line is hit, I am not seeing any advancement. Could this be a webpack issue?
I think this might the same issue described here
So apparently npm install takes too long during automated deployments
on t1.micro instances, bumping to a t2.small gives enough power to get
the task done.
There is an alternative js only module just called sass. Seems to work ok, but not as up to date as none-sass.