0
votes

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)"
  ]
}
1
It seems you are using an older version of the guide. The new guide is posted here. Check 2019 revision. docs.aws.amazon.com/solutions/latest/serverless-image-handler/… Or you can follow the below steps on this link to build the image directly. github.com/awslabs/serverless-image-handlersidharth arora
where can i get latest zip folder of source code?Sagar Bhagdev
Click Green Button to download option github.com/awslabs/serverless-image-handlersidharth arora
no that's a different code, checkout zip file in old articleSagar Bhagdev

1 Answers

0
votes

Steps to fix it: -

  1. Download your project(function) form AWS Lambda using Action->Export function and unzip it.

enter image description here

  1. Install Latest version of node in your local system(say node 8.10.0). You can see i already have 8.10.0.

enter image description here

  1. Go to your unzipped project folder via terminal and type

    npm rebuild

enter image description here

  1. 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