![](/img/trans.png)
[英]Deploying cloud functions on cli, “Firebase config variables are not available.”
[英]Firebase config variables are not available error with deploying functions
當我部署 Firebase 函數時
admin.initializeApp(functions.config().firebase);
Firebase 日志
錯誤:默認 Firebase 應用不存在。 確保在使用任何 Firebase 服務之前調用 initializeApp()。
但是如果我添加那一行,我會在部署時出錯。
>firebase deploy --only functions
錯誤:
錯誤:解析函數觸發器時出錯。 請通過在您的函數文件夾中運行“npm i --save firebase-functions@latest”來確保您擁有最新的 firebase-functions SDK。
錯誤:Firebase 配置變量不可用。 請使用最新版本的 Firebase CLI 部署此功能。
我已經做了npm i --save firebase-functions@latest
沒有做任何事情。 由於這個原因,我被卡住了,現在無法做任何事情......如果他們可以幫助我告訴我一些步驟或提示,我會尋求其他任何重新安裝。
NPM 和 NodeJS 版本是:
node -v
v8.9.1
npm -v
5.6.0
編輯。 使用管理員權限安裝:
npm i --save firebase-functions@latest
npm WARN firebase-functions@0.8.1 requires a peer of firebase-admin@~5.8.1 but none is installed. You must install peer dependencies yourself.
npm ERR! path C:\Users\Telion\firebaseApps\project-name\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\abbrev
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Telion\firebaseApps\project-name\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\abbrev' -> 'C:\Users\Telion\firebaseApps\project-name\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\.abbrev.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
實際上,我使用的是 npm 版本 5.5.1,但即使在更新到 5.6.0 之后,我也遇到了完全相同的錯誤。
firebase-tools@3.17.x
中引入了一項重大更改,需要您的項目將firebase-functions
升級到最新版本。
但是, firebase-functions@latest
也需要firebase-admin@latest
(在撰寫此答案時firebase-admin@5.11.0
。一旦所有軟件包都升級,這個問題應該可以解決。
另一種選擇是將全局3.16.0
firebase-tools
降級到3.16.0
,這樣您就可以使用較舊的firebase-functions
和firebase-admin
軟件包。
對我來說,它適用於 firebase-tools6.9.2。 firebase-tools3.16.0 已完全棄用。
我在 Ubuntu 中遇到了同樣的問題,這就是我解決它的方法
使用以下sudo npm install -g firebase-tools
安裝 firebase: sudo npm install -g firebase-tools
還要確保您使用管理員權限啟動,例如登錄
sudo firebase login
您還需要將節點更新到至少 8.15.x。 該詳細信息顯示在消息中。
一旦我安裝了我必須執行firebase login
命令,然后您就可以運行firebase init hosting
以前我在firebase init hosting
上遇到錯誤,但在該節點更新后,它消失了。
希望它有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.