的火力地堡雲功能是最近剛剛發佈,我下面就一個新的說明進行安裝。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」文件夾內,因此也有問題,因爲最初放在根目錄下。 –