【问题标题】:Getting error when deploying a Google Cloud Function after Node upgrade节点升级后部署 Google Cloud 函数时出错
【发布时间】:2020-06-03 02:34:35
【问题描述】:

我更新了Brew,然后从10.12.0 -> 13.8.0更新了Node

现在,我在尝试部署 Google Cloud 函数时收到以下错误

firebase deploy --only functions:createJWT

i 函数:准备函数目录 上传中...

错误:解析触发器错误:无法加载 gRPC 二进制模块 因为它没有为当前系统安装预期 目录:node-v79-darwin-x64-unknown 找到: [node-v64-darwin-x64-unknown] 这个问题通常可以通过 在当前系统上运行“npm rebuild”原始错误:不能 查找模块 '/Users/.../cloud-functions/functions/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown/grpc_node.node' 需要堆栈: - /Users/.../cloud-functions/functions/node_modules/grpc/src/grpc_extension.js - /Users/.../cloud-functions/functions/node_modules/grpc/src/client_interceptors.js - /Users/.../cloud-functions/functions/node_modules/grpc/src/client.js - /Users/.../cloud-functions/functions/node_modules/grpc/index.js - /Users/.../cloud-functions/functions/node_modules/@google-cloud/common-grpc/src/service.js - /Users/.../cloud-functions/functions/node_modules/@google-cloud/common-grpc/src/operation.js - /Users/.../cloud-functions/functions/node_modules/@google-cloud/common-grpc/src/index.js - /Users/.../cloud-functions/functions/node_modules/@google-cloud/logging/src/index.js - /Users/.../cloud-functions/functions/index.js - /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js

尝试在您的函数目录中运行“npm install”之前 部署。

在我的函数目录中尝试了npm rebuildnpm install,但没有任何效果

此外...这个问题可能是由于 GCF Node 运行时环境是 Node10 并且我在我的机器上安装了 Node13 造成的吗? - 根据这些文档:

https://cloud.google.com/functions/docs/concepts/nodejs-10-runtime

我正在努力恢复到 Node10,尝试运行 brew install node@10 并得到这个:

然后尝试根据上面的输出运行以下命令,将其符号链接到/usr/local,但仍然没有运气

echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"' >> ~/.bash_profile

【问题讨论】:

    标签: node.js google-cloud-functions


    【解决方案1】:

    搜索这个错误,确实,这似乎与您的系统等待一个版本并创建另一个版本有关 - 根据这部分错误。

    错误:解析触发器错误:加载 gRPC 二进制模块失败,因为它没有为当前系统安装预期目录:node-v79-darwin-x64-unknown 找到:[node-v64-darwin-x64-unknown]

    除了尝试npm rebuild 之外,您还可以尝试一些选项。另一种选择可能是更新package.json - 根据这种情况已解决here - 这会将您的npm版本恢复为旧版本。

    除此之外,关于社区中的这个问题,有一些解决方案可以帮助其他用户,我建议你看看它:NodeJs Error - Failed to load gRPC binary module because it was not installed for the current system Expected directory?

    如果这些信息对您有帮助,请告诉我!

    【讨论】:

    • 我的package.json 指定"node": "10" 如果我更改为12 我得到Error: The only valid choices are: {"node": "8"} and {"node": "10"} 当我运行firebase deploy functions....所以如果我的想法是错误的请纠正我,我的机器有node 13.8 并尝试部署到 node10 Google env 不喜欢它?
    • 嗨,@Roggie 查看官方文档,似乎支持Node.js 8Node.js 10 仍处于测试阶段。这证实了 Cloud Functions 确实不支持 Node.js 13 还受支持。我建议您向它提出功能请求here,以便 Google 对此进行检查。
    • 是的,尝试从更高版本部署是问题所在,回到node10.19.0 工作正常。
    • 不错!感谢您确认,@Roggie!
    • @Roggie 如果您认为有帮助,请考虑接受或支持我的回答!
    【解决方案2】:

    尝试部署到不受支持的 Google 函数执行环境将不起作用。根据谷歌docs,当前支持的环境是Node8Node10(beta),重新安装Node10对我有用。

    【讨论】:

      猜你喜欢
      • 2021-08-23
      • 2020-01-19
      • 2019-12-30
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多