Firebase 函数部署导致“构建环境中的错误”

分享于2023年04月29日 firebase firebase-cli google-cloud-functions google-cloud-platform node.js 问答
【问题标题】:Firebase functions deploy results in "Error in the build environment"Firebase 函数部署导致“构建环境中的错误”
【发布时间】:2023-04-28 12:17:01
【问题描述】:

当我尝试使用 firebase-tools cli 部署函数时,我总是收到每个函数的部署错误。输出如下所示:

!  functions[import]: Deployment error.
Error in the build environment

我尝试过不同的部署方式:

firebase deploy --only functions

firebase deploy --only functions:[function-name]

两者都会导致部署错误。打包的函数文件夹上传成功。 有什么方法可以更新我当前的功能吗?

  • 如果您在部署过程中看到没有帮助的错误,请务必检查遗留的 firebase-debug.log 文件,或者在启用调试的情况下再次运行 firebase deploy --debug 。这可能包含要分享的有用信息。
  • 我已经尝试过了,但我找不到任何有关导致错误的信息。我已经在 firebase-tools 存储库上提交了一个问题。在那里你可以找到我的 firebase-debug.log - github.com/firebase/firebase-tools/issues/630
  • 请联系 Firebase 支持,尽可能多地了解您的项目。 firebase.google.com/support/contact/troubleshooting
  • 也试过了;)。我只是等待他们的回应。谢谢道格!

【解决方案1】:

我按照@Jirawatee 的建议做了,但后来我的节点版本出现了一些问题。 所以我将我的节点版本更改为 V8,并在 package.json 中添加了引擎密钥。然后删除我的节点模块,重新安装它们并再次尝试部署

所以:

1.) 安装更新

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools

2.) 将您的全局节点版本更改为 8 我个人使用 Nodist for Windows 来管理我的节点版本

3.) 将引擎添加到 package.json

  "engines": {
    "node": "8"
  },

4.) 删除并重新安装节点模块

rm -rf node_modules && npm install

5.) 最后,运行您的 firebase 构建/部署脚本

【讨论】: