如何修复 Aws-lambda 函数中的 nodejs 版本问题
How to fix nodejs version issue in Aws-lambda function
我试图在 Aws lambda 的帮助下调整图像大小,但出现错误
我正在关注这篇文章
{
"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)"
]
}
修复步骤:-
- 使用 Action->Export 函数从 AWS Lambda 下载您的项目(函数)并解压缩。
- 在您的本地系统中安装最新版本的节点(比如节点 8.10.0)。你可以看到我已经有 8.10.0.
通过终端转到解压缩的项目文件夹并键入
npm rebuild
- 在此之后再次压缩该项目并将其上传到 AWS Lambda 和 select 您更新的节点运行时(假设它是节点 8.10.0 然后 select aws lambda 函数运行时中的运行时作为节点 8.10x).
希望对您有所帮助。
谢谢
我试图在 Aws lambda 的帮助下调整图像大小,但出现错误 我正在关注这篇文章
{
"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)"
]
}
修复步骤:-
- 使用 Action->Export 函数从 AWS Lambda 下载您的项目(函数)并解压缩。
- 在您的本地系统中安装最新版本的节点(比如节点 8.10.0)。你可以看到我已经有 8.10.0.
通过终端转到解压缩的项目文件夹并键入
npm rebuild
- 在此之后再次压缩该项目并将其上传到 AWS Lambda 和 select 您更新的节点运行时(假设它是节点 8.10.0 然后 select aws lambda 函数运行时中的运行时作为节点 8.10x).
希望对您有所帮助。
谢谢