当我在我的无服务器应用程序中调用任何函数时,我会得到一个错误,如下所示。然而,直接安装夏普给我没有错误。而且,当我运行测试时,sharp非常有效。
节点模块中存在缺失模块“:/build/Release/Shar-Darn-x64节点”
Error:
Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp-darwin-x64.node'
Require stack:
- /.esbuild/.build/src/functions/function1/handler.js
系统:
已尝试的解决办法:
发布于 2022-05-20 02:14:25
根据正式文件,试着安装夏普。
npm install --arch=x64 --platform=darwin sharp
对于使用Sharp模块进行AWS部署,在使用无服务器、esbuild和时,以下内容对我起了作用使用以下配置更改了serverless.yml文件。考虑到您的lambda使用的是,= x64 -platform=linux,这基本上告诉您再次下载x64。有关更多理解,请查看无服务器构建、、packager和选项。
esbuild:
# keep existing configurations
external:
- sharp
packagerOptions:
scripts:
- npm install --arch=x64 --platform=linux sharp
https://stackoverflow.com/questions/70566288
复制相似问题