我已将 Vue.js 应用程序推送到暂存网站。
当我使用本地后端运行应用程序时,一切正常。我能够使用 sharp 模块裁剪图像,它们被保存到 AWS S3 存储桶并正确显示。
但是,一旦我尝试使用 claudia update 将服务器部署到 AWS Lambda,它就无法在实时站点上运行。我认为这是因为节点模块安装干净,出于某种原因 AWS 找不到该模块(即使我可以在本地机器上下载它)。
有谁知道我该如何解决这个问题?提前致谢!
{
"errorType": "Error",
"errorMessage": "\nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-linux-x64.node'\n\nPossible solutions:\n- Install with the --verbose flag and look for errors: \"npm install --ignore-scripts=false --verbose sharp\"\n- Install for the current runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install",
"stack": [
"Error: ",
"Something went wrong installing the \"sharp\" module",
"",
"Cannot find module '../build/Release/sharp-linux-x64.node'",
"",
"Possible solutions:",
"- Install with the --verbose flag and look for errors: \"npm install --ignore-scripts=false --verbose sharp\"",
"- Install for the current runtime: \"npm install --platform=linux --arch=x64 sharp\"",
"- Consult the installation documentation: https://sharp.pixelplumbing.com/install",
" at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:30:9)",
" 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 Module.require (internal/modules/cjs/loader.js:692:17)",
" at require (internal/modules/cjs/helpers.js:25:18)",
" at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:8:1)",
" at Module._compile (internal/modules/cjs/loader.js:778:30)"
]
}
最佳答案
当你安装sharp时使用:
npm install --platform=linux --arch=x64 sharp
代替:
npm install sharp
关于aws-lambda - 安装 "sharp"模块时出错 (AWS Lambda),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70415970/