Firebase AWS Lambda错误:无法加载gRPC二进制模块,因为当前系统未安装该模块

Firebase AWS Lambda错误:无法加载gRPC二进制模块,因为当前系统未安装该模块,firebase,aws-lambda,glibc,google-cloud-firestore,grpc,Firebase,Aws Lambda,Glibc,Google Cloud Firestore,Grpc,我对AWS Lambda功能在无服务器框架下的部署有问题。我使用@googlecloudfirestorenpm包,它需要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-da

我对AWS Lambda功能在无服务器框架下的部署有问题。我使用
@googlecloudfirestore
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)"
  ]
}
{
“errorMessage”:“无法加载gRPC二进制模块,因为它不是为当前系统安装的\n预期目录:node-v48-linux-x64-glibc\n查找:[node-v59-darwin-x64-unknown]\n此问题通常可以通过运行\“npm rebuild”来解决\“在当前系统上\n原始错误:找不到模块'/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node'”,
“errorType”:“Error”,
“stackTrace”:[
“找到:[node-v48-linux-x64-unknown]”,
“此问题通常可以通过在当前系统上运行“npm rebuild”来解决”,
“原始错误:找不到模块'/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node',
“对象。(/var/task/node_modules/grpc/src/grpc_extension.js:44:17)”,
“模块编译(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)”,
“要求(内部/module.js:20:19)”,
“对象。(/var/task/node_modules/grpc/src/client.js:38:12)”,
“模块编译(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)”,
“需要(内部/module.js:20:19)”
]
}
因此,据我所知,lambda需要使用target
node-v48-linux-x64-glibc构建GRP

键入
npmi-sgrpc--target=6.4.0--target\u arch=x64--target\u platform=linux
只将
node-v59-darwin-x64-unknown
更改为
node-v48-linux-x64-unknown

如何将
unknown
更改为
glibc


任何帮助都将不胜感激。

我得到了与工作类似的东西,包括一个
--target\u libc=glibc
,可在中找到。

基本上,您需要指定grcp库的目标。 从该链接复制:

{
  "main": "index.js",
  "scripts": {
  "postinstall": "npm rebuild grpc --target=6.1.0 --target_arch=x64 --target_platform=linux --target_libc=glibc"
  }
}

可能有更好的解决方案,但我想到的一个明显的解决方案是在使用创建的计算机上构建模块。起初对此有点困惑,但意识到这是一个本地安装步骤,而不是服务器上发生的任何事情。我使用的是node 8.10.0,所以一旦我将其更改为该版本,
npm install
在部署之前,它在本地运行得很好。感谢您的洞察力!我尝试了一下,但仍然没有成功。我需要在AWS中进行一些配置吗?得到以下错误:“errorMessage”“:
/var/task/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node:ELF头无效
。还尝试添加了
--update binary
标志,但无效。