Firebase CLI always shows Error: Invalid project id: \
Asked Answered
C

8

7

Every time I use a firebase command this error occurs:

...\WEBRTCTest\FirebaseRTC> firebase use --add

Error: Invalid project id: \.
\WEBRTCTest\FirebaseRTC> firebase use --clear

Error: Invalid project id: \.

The error occured after I accidently run the command:

firebase use \

Prior to that all was working fine.

I tried to reinstall firebase-tools using npm and also re-cloning the example project from github. Also tried to logout using firebase logout but it gives me the same error:

\WEBRTCTest\FirebaseRTC> firebase use --clear

Error: Invalid project id: \.

I´m thankful for any idea as i´m stuck right now.

Chalmers answered 4/4, 2020 at 12:28 Comment(0)
M
18

It seems Firebase CLI can get into a bad state if you accidentally use an invalid project name, then all commands will fail, even firebase use --clear (I'm using version 8.2.0)

This happens even if there is no .firebaserc file.

I got it to work by finding a valid project name in my Firebase Console on console.firebase.google.com and then run the firebase command use --clear but overriding the active project with the --project parameter indicating a valid project name, like this:

$ firebase use --clear --project="myvalidprojectname"
Cleared active project.

Run firebase use --add to define a new project alias.

Then subsequent commands will run smoothly.

Monotint answered 4/5, 2020 at 23:7 Comment(4)
Thank you for this, it really worked for me and I had to use the project ID as shown in the project settings on Firebase.Gillead
Your answer saved me a lot of hassle. Thanks a lot!Boatbill
This is the correct answer guys.Butler
It worked for me guys.Forsta
C
2

i had to delete the .firebaserc file ( to the all commands work again

Cursorial answered 24/9, 2021 at 12:57 Comment(0)
P
1

Have you considered explicitly telling firebase what project to use?


# get list of projects
$ firebase projects:list

# add project id to most firebase CLI commands 
$ firebase <my command> --project=<my project ID>

Pickford answered 4/4, 2020 at 12:32 Comment(1)
Thank you for the answer, but it did not work. I got the same error trying both commands.Chalmers
C
1

Not sure why it works now. But I found a work-around: It´s working again after cloning the project in a new folder.

Chalmers answered 4/4, 2020 at 12:53 Comment(1)
Yes, this worked for me. I believe this is an issue with the firebase command. No need to copy and paste though, just rename the folder to something else and it works!Oriel
C
1

In my case, I changed the "default" in .firebaserc, then it works:

From:

{
    "projects": {
        "default": "YOUR DEFAULT PROJECT ID"
    }
}

TO my project id "pwa-proj"

{
    "projects": {
        "default": "pwa-proj"
    }
}
Couldst answered 3/6, 2020 at 0:40 Comment(1)
Can you include inline code span so the code is readable & verifiable.Lucero
S
1

In my case where I am using Angular, I also had to change angular.json

{
    "projects": {
        "YOUR_PROJECT_ID": { ... }
    }
}   
Shakira answered 2/5 at 23:28 Comment(0)
T
0

The Firebase CLI keeps information about the current project in a (hidden) file called .firebaserc. It looks like your .firebaserc file got corrupted, so you might want to delete the file and then run firebase use or firebase add again .

Tiphane answered 4/4, 2020 at 14:25 Comment(0)
G
0

I came a cross this problem and realized that there was another firebase.js file in the same folder as my project folder. When I deleted that firebase file, boom! it worked. Just check to see that there is no other firebase.js file that could be read from apart from the one you intend to be read from.

Glucoside answered 26/7, 2021 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.