我在使用无服务器框架部署 AWS Lambda 函数时遇到问题。我用@google-cloud-firestore
npm 包需要 grpc
包。
函数执行抛出错误:
{
"errorMessage": "Failed to load gRPC binary module because it was not installed for the current system\nExpected directory: node-v48-linux-x64-glibc\nFound: [node-v59-darwin-x64-unknown]\nThis problem can often be fixed by running \"npm rebuild\" on the current system\nOriginal error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node'",
"errorType": "Error",
"stackTrace": [
"Found: [node-v48-linux-x64-unknown]",
"This problem can often be fixed by running \"npm rebuild\" on the current system",
"Original error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node'",
"Object.<anonymous> (/var/task/node_modules/grpc/src/grpc_extension.js:44:17)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object.<anonymous> (/var/task/node_modules/grpc/src/client.js:38:12)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)"
]
}
因此,据我了解,lambda 需要使用目标 node-v48-linux-x64-glibc
构建的 grps
打字 npm i -S grpc --target=6.4.0 --target_arch=x64 --target_platform=linux
只改变了node-v59-darwin-x64-unknown
至node-v48-linux-x64-unknown
.
我该如何更改unknown
至glibc
?
任何帮助将不胜感激!
最佳答案
基本上,您需要指定 grcp 库的目标。 从该链接复制:
{
"main": "index.js",
"scripts": {
"postinstall": "npm rebuild grpc --target=6.1.0 --target_arch=x64 --target_platform=linux --target_libc=glibc"
}
}
关于firebase - AWS Lambda错误: Failed to load gRPC binary module because it was not installed for the current system,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47979568/