aws-lambda - 安装 "sharp"模块时出错 (AWS Lambda)

标签 aws-lambda node-modules npm-install sharp claudiajs

我已将 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/

相关文章:

javascript - phantomjs 在访问 aws-sdk 时找不到 Node 模块 'crypto'

javascript - 如何使用 Node 写入文件

javascript - 在 'npm start' 命令中自定义构建目录

node.js - Termux - npm ERR!错误 : EPERM: operation not permitted

.net-core - 如何在 C# Lambda Core 中发布 SNS 消息

node.js - 通过 aws codebuild 为 nodejs lambda 创建 zip 文件的问题

python - Lambda 代理响应格式错误 : deploying python endpoints through serverless

aws-lambda - 如何检测用户何时结束与 Alexa 的交互?

angular - 升级到 native 脚本 8.1.5 后出现节点模块问题

npm install 需要很长时间,说我在代理后面