的火力地堡云功能是最近刚刚发布,我下面就一个新的说明进行安装。Here is the "Get Started" page.“functions.config()不可用‘与火力地堡如何使用Node.js云功能
我已经安装了’ npm install -g firebase-tools“和我所有的文件都在我的项目中,我正在使用WebStorm 2016.3和Node.JS v6.10.0。
我已经安装并设置了firebase登录和firebase init函数。 我的设置
我的包age.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"firebase-admin": "^4.1.2",
"firebase-functions": "^0.5"
},
"private": true
}
这些前两行代码工作。
const functions = require('firebase-functions');
const admin = require('firebase-admin');
但是当我尝试运行这条线......
admin.initializeApp(functions.config().firebase);
我得到这个错误。
Error: functions.config() is not available. Please use the latest version of the Firebase CLI to deploy this function.
at init (/Users/.../functions/node_modules/firebase-functions/lib/config.js:46:19)
at Object.config (/Users/.../functions/node_modules/firebase-functions/lib/config.js:29:9)
at Object.<anonymous> (/Users/.../functions/index.js:11:31)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
我在这里错过了什么?
对我而言,它使用了其他环境变量。我在相邻页面上找到了答案,该页面说创建本地运行时配置以复制实际的配置文件,因为该配置仅适用于部署的代码。对于本地,运行这个'firebase functions:config:get> .runtimeconfig.json'。 –
这帮助我了解如何在部署之前在本地进行测试:https://firebase.google.com/docs/functions/local-emulator – cking24343
@MartavisP。你救了我的一天!重要说明:.runtimeconfig.json应放置在“functions”文件夹内,因此也有问题,因为最初放在根目录下。 –