`firebase deploy` with CLI tools 3.17.0 gives "Error: Firebase config variables are not available"

`firebase deploy` with CLI tools 3.17.0 gives "Error: Firebase config variables are not available"

完整错误转储:

Error: Error occurred while parsing your function triggers. Please ensure you have the latest firebase-functions SDK by running "npm i --save firebase-functions@latest" inside your functions folder.

Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
    at init (/Users/dougstevenson/work/google/firebase/functions/tmp/functions/node_modules/firebase-functions/lib/config.js:51:15)
    at Object.config (/Users/dougstevenson/work/google/firebase/functions/tmp/functions/node_modules/firebase-functions/lib/config.js:29:9)
    at Object.ref (/Users/dougstevenson/work/google/firebase/functions/tmp/functions/node_modules/firebase-functions/lib/providers/database.js:75:33)
    at Object.<anonymous> (/Users/dougstevenson/work/google/firebase/functions/tmp/functions/lib/index.js:9:32)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)

对于 firebase-tools(Firebase CLI)版本 3.17.0,需要使用最新的 firebase-functions(版本 0.8.1)和 firebase-admin(版本 5.8.1)SDK。通过 functions 文件夹中的 运行 此命令更新它们:

npm install firebase-functions@latest firebase-admin@latest

在此之后,部署应该会成功。

编辑:此错误已在 CLI 版本 3.17.1 中修复。当 运行 带有 CLI 的模拟器时也会出现类似的错误,并且已在 3.17.3 中修复。

要解决此问题,我需要从您的 firebase 函数文件夹的根路径 运行:

npm update -g firebase-functions;

运行 再来一次..

npm update -g firebase-functions;

然后根据上述建议更新函数目录中的 node_modules

cd functions;
npm install firebase-functions@latest firebase-admin@latest;

注意:有趣的是,NPM 抱怨这两个包的安装无效,即使在 运行ning 再次安装之后也是如此。但是执行 firebase deploy --only functions 效果很好。

顺便说一句,对于那些不喜欢在一个大 index.js 文件中工作的人来说,我的简单部署快捷脚本可能会派上用场:

#!/bin/bash

(cd functions/; cat header.js get*.js process*.js set* > index.js; );

firebase deploy --only functions

say "fire base deploy done";