aws-samples / image-optimization

Simple, performant and cost efficient solution for optimizing images using Amazon CloudFront, Amazon S3 and AWS Lambda
MIT No Attribution
172 stars 106 forks source link

Unable to find a working version of libraries. Sharp and aws-cdk does not support Node-16, Node-18 error out with aws-sdk not found. #28

Closed yangcheng closed 6 months ago

yangcheng commented 6 months ago
2024-01-15T09:15:25.547Z    undefined   ERROR   Uncaught Exception  {"errorType":"Error","errorMessage":"Could not load the \"sharp\" module using the linux-x64 runtime
Possible solutions:
- Please upgrade Node.js:
    Found 16.20.2
    Requires ^18.17.0 || ^20.3.0 || >=21.0.0
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install","stack":["Error: Could not load the \"sharp\" module using the linux-x64 runtime","Possible solutions:","- Please upgrade Node.js:","    Found 16.20.2","    Requires ^18.17.0 || ^20.3.0 || >=21.0.0","- Consult the installation documentation:","    See https://sharp.pixelplumbing.com/install","    at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:114:9)","    at Module._compile (node:internal/modules/cjs/loader:1198:14)","    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)","    at Module.load (node:internal/modules/cjs/loader:1076:32)","    at Function.Module._load (node:internal/modules/cjs/loader:911:12)","    at Module.require (node:internal/modules/cjs/loader:1100:19)","    at require (node:internal/modules/cjs/helpers:119:18)","    at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:10:1)","    at Module._compile (node:internal/modules/cjs/loader:1198:14)","    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)"]}

After I upgrade runtime: lambda.Runtime.NODEJS_16_X, to runtime:lambda.Runtime.NODEJS_16_X, I got the following error. And NODEJS_20 seems not defined by cdk. likely due to this issue not closed? https://github.com/aws/aws-cdk/issues/27003


2024-01-15T09:24:43.647Z    undefined   ERROR   Uncaught Exception  {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'aws-sdk'
Require stack:
- /var/task/index.js
- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'","Require stack:","- /var/task/index.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:1087:17)","    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)","    at async start (file:///var/runtime/index.mjs:1282:23)","    at async file:///var/runtime/index.mjs:1288:1"]}

I also tried to use node-16 locally, but it does not work with cdk, Screenshot 2024-01-15 at 5 50 04 PM

Is it possible for the repo to get an upgrade of major depedencies?

yangcheng commented 6 months ago

nvm. I noticed the latest main has upgrade to node-20