firebase - AWS Lambda错误: Failed to load gRPC binary module because it was not installed for the current system

标签 firebase aws-lambda glibc google-cloud-firestore grpc

我在使用无服务器框架部署 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-unknownnode-v48-linux-x64-unknown .

我该如何更改unknownglibc

任何帮助将不胜感激!

最佳答案

Fix

基本上,您需要指定 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/

相关文章:

posix - 当给定一个包含无法识别的可执行魔数(Magic Number)的文件时,posix_spawn() 应该如何表现?

angular - 如何只订阅 firebase 集合更改

node.js - 通过 http 对 aws 资源的请求进行正确签名

node.js - 如何通过 AWS lambda 函数使用 Amazon SNS 发送短信

javascript - 无法从 Java Lambda 函数获取 CognitoIdentityId

c - 在使用 fmemopen 打开的 FILE* 上使用 rewind()

linux - 在汇编中使用 printf 会导致管道传输时输出为空,但可以在终端上使用

firebase - 使用流检查身份验证状态在 Flutter 中不起作用

javascript - AngularJS:未捕获错误:[$injector:modulerr] 与 firebase

swift - Firebase 在 Swift 中返回句柄和引用的正确方法是什么