【问题标题】:`firebase deploy` with CLI tools 3.17.0 gives "Error: Firebase config variables are not available"使用 CLI 工具 3.17.0 的`firebase deploy` 给出“错误:Firebase 配置变量不可用”
【发布时间】:2018-06-27 23:40:54
【问题描述】:

完整的错误转储:

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 google-cloud-functions firebase-tools


    【解决方案1】:

    使用 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-anything:firebase-admin@5.8.1firebase-functions@0.8.1firebase-tools@3.17.1
    • 回滚到firebase-tools@3.16.0(但留下firebase-admin@5.8.1firebase-functions@0.8.1)为我修复了它,所以新版本的firebase-tools 有一些问题。
    • 这些解决方案都不适合我。还有其他可能导致问题的原因吗?
    • @Sam 您收到的是 exact 相同形式的错误消息,还是类似但不同的错误消息?如果错误的形式不同(即使消息相同),您应该在不同的问题中提出不同的问题。
    • 谢谢@DougStevenson。回滚到 3.16.0 暂时修复它。
    【解决方案2】:

    为了解决这个问题,我需要从你的 firebase 函数文件夹的根路径运行:

    npm update -g firebase-functions;
    

    再次运行它..

    npm update -g firebase-functions;
    

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

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

    注意:有趣的是,NPM 抱怨这两个包的安装都是无效的,即使在再次运行 install 之后也是如此。但是执行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";
    

    【讨论】:

      猜你喜欢
      • 2018-08-17
      • 2018-10-12
      • 2018-07-09
      • 2018-05-19
      • 1970-01-01
      • 2021-05-12
      • 2019-03-30
      • 2018-08-14
      相关资源
      最近更新 更多