[英]Firebase config variables are not available error with deploying functions
When I am deploying Firebase functions without当我部署 Firebase 函数时
admin.initializeApp(functions.config().firebase);
Firebase logs Firebase 日志
Error: The default Firebase app does not exist.
错误:默认 Firebase 应用不存在。 Make sure you call initializeApp() before using any of the Firebase services.
确保在使用任何 Firebase 服务之前调用 initializeApp()。
But if I add that line I get error on deploy.但是如果我添加那一行,我会在部署时出错。
>firebase deploy --only functions
Error:错误:
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.
请通过在您的函数文件夹中运行“npm i --save firebase-functions@latest”来确保您拥有最新的 firebase-functions SDK。
Error: Firebase config variables are not available.
错误:Firebase 配置变量不可用。 Please use the latest version of the Firebase CLI to deploy this function.
请使用最新版本的 Firebase CLI 部署此功能。
I already did npm i --save firebase-functions@latest
which haven't done anything.我已经做了
npm i --save firebase-functions@latest
没有做任何事情。 I am stuck and can't do anything right now because of this... I am down for any reinstalls if they could help just tell me some steps or hints and I would seek for the rest.由于这个原因,我被卡住了,现在无法做任何事情......如果他们可以帮助我告诉我一些步骤或提示,我会寻求其他任何重新安装。
NPM and NodeJS versions are: NPM 和 NodeJS 版本是:
node -v
v8.9.1
npm -v
5.6.0
Edit.编辑。 Installation with admin rights:
使用管理员权限安装:
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
It actually appeared I was on npm version 5.5.1 but even after the update to 5.6.0 I got the exact same error.实际上,我使用的是 npm 版本 5.5.1,但即使在更新到 5.6.0 之后,我也遇到了完全相同的错误。
There was a breaking change introduced in firebase-tools@3.17.x
which requires your project to upgrade firebase-functions
to the latest version. firebase-tools@3.17.x
中引入了一项重大更改,需要您的项目将firebase-functions
升级到最新版本。
However, firebase-functions@latest
also requires firebase-admin@latest
(at the time of writing this answer firebase-admin@5.11.0
. Once all packages are upgraded, this problem should be solved.但是,
firebase-functions@latest
也需要firebase-admin@latest
(在撰写此答案时firebase-admin@5.11.0
。一旦所有软件包都升级,这个问题应该可以解决。
Another alternative is to downgrade your global firebase-tools
to 3.16.0
, which lets you use older firebase-functions
and firebase-admin
packages.另一种选择是将全局
3.16.0
firebase-tools
降级到3.16.0
,这样您就可以使用较旧的firebase-functions
和firebase-admin
软件包。
For me, it worked for firebase-tools6.9.2.对我来说,它适用于 firebase-tools6.9.2。 The firebase-tools3.16.0 is completely depricated.
firebase-tools3.16.0 已完全弃用。
I ran into the same issue in Ubuntu and this is how i solved it我在 Ubuntu 中遇到了同样的问题,这就是我解决它的方法
Install firebase using : sudo npm install -g firebase-tools
使用以下
sudo npm install -g firebase-tools
安装 firebase: sudo npm install -g firebase-tools
Also make sure you launch using admin privileges eg to login还要确保您使用管理员权限启动,例如登录
sudo firebase login
You also need to update the node to at least 8.15.x.您还需要将节点更新到至少 8.15.x。 That detail is shown in the message.
该详细信息显示在消息中。
Once I intalled that I had to do a firebase login
command and after that you can run the firebase init hosting
一旦我安装了我必须执行
firebase login
命令,然后您就可以运行firebase init hosting
Previously I was getting the error on firebase init hosting
but after that node update, it went away.以前我在
firebase init hosting
上遇到错误,但在该节点更新后,它消失了。
Hope it helps.希望它有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.