简体   繁体   中英

Firebase config variables are not available error with deploying functions

When I am deploying Firebase functions without

admin.initializeApp(functions.config().firebase);

Firebase logs

Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.

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.

Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.

I already did npm i --save firebase-functions@latest which haven't done anything. 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:

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.

There was a breaking change introduced in firebase-tools@3.17.x which requires your project to upgrade firebase-functions to the latest version.

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.

Another alternative is to downgrade your global firebase-tools to 3.16.0 , which lets you use older firebase-functions and firebase-admin packages.

For me, it worked for firebase-tools6.9.2. The firebase-tools3.16.0 is completely depricated.

I ran into the same issue in Ubuntu and this is how i solved it

Install firebase using : 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. 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

Previously I was getting the error on firebase init hosting but after that node update, it went away.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM