33

I have recently had an issue with my firebase account where any new projects don't show in the CLI when I run firebase init. I deleted a project I didn't need, and that updated immediately, any help is greatly appreciated!

Max S.
  • 455
  • 1
  • 5
  • 10

10 Answers10

50

There is a simpler solution, first, determine your projectId from the Firebase Console. Firebase usually adds a random number to your project's name i.e if you are using demo as the project name the projectId will look like demo-1234

Next, in your terminal, cd into your project's target directory and issue the followoing command

firebase -P <projectId> init

assuming demo-1234 was my projectId, I will issue the command as below

firebase -P demo-1234 init

  • This worked for me. when I used ```firebase init``` without the project name, it'd tell me to add project first. When I tried to use ```firebase use --add ``` it'd tell me to init the folder first. Finally, this person's solution worked for me. – J.Ko Jan 05 '19 at 06:44
  • In the last step it only worked when I used "Don't Setup a default project" option. – Lalit Rane Oct 22 '19 at 11:21
19

Use firebase use --add projectId, this will add your project

AmerllicA
  • 29,059
  • 15
  • 130
  • 154
Dragon
  • 467
  • 2
  • 5
  • 13
8

Yea this is a weird one.

Use the [don't setup a default project] option

then, as mentioned by @Dragon, use firebase use --add projectId to add the project

Va5ili5
  • 749
  • 8
  • 20
6

I did

firebase logout

then

firebase login

It works for me

Khay Leng
  • 391
  • 5
  • 8
2

Check with firebase login.

You will get redirected to browser and just do sign in.

then firebase -P <Project-ID> init Then follow all options that come along.

"Which Firebase CLI features do you want to set up for this folder?" Choose "Hosting: Configure and deploy Firebase Hosting sites."

"Select a default Firebase project for this directory:" Choose the project you created on the Firebase website.

"What do you want to use as your public directory?" Enter "build".

Configure as a single-page app (rewrite all urls to /index.html)?" Enter "Yes".

"File build/index.html already exists. Overwrite?" Enter "No".

Kapil Raghuwanshi
  • 867
  • 1
  • 13
  • 22
2

The quickest way to do when initializing is by using the --project option:

firebase init --project <projectId>

Stan_MD
  • 1,011
  • 9
  • 8
0

The below solution worked for me.

  1. Get the Project Id from firebase console. e.g. myproject-2233

  2. On Firebase CLI run below command $ firebase -P myproject-2233

  3. Next Select the features you want to add e.g. Web Hosting

  4. Next Select "Don't Setup a default project"
  5. Give the public folder name

It worked only after choosing "Don't Setup a default project"

##

Lalit Rane
  • 850
  • 10
  • 16
0

For me, turns out I was logged into the Firebase CLI using a different account from the one that created the project. The solution was either to log into the CLI with the account that created the project with:

firebase login

or, using the Firebase console, invite the user who's logged into the CLI

kip2
  • 6,473
  • 4
  • 55
  • 72
0

Just do a refresh in your firebase console, sometimes the firebase auth token is expired. I had the same issue and after refreshing it fixed for me.

Pramod Ukkali
  • 261
  • 2
  • 2
0

if you are using mac and npm

  1. add on terminal: sudo npm install -g firebase-tools

  2. firebase login (check your login console accounts are same)

    firebase projects:list (list all your firebase project)

  3. cd to your project (go to your project folder and right click then go to new terminal at folder on this terminal write pwd you can get the path of the folder after that close the terminal )

  4. type on at root folder terminal: dart pub global activate flutterfire_cli

  5. write on terminal : export PATH="$PATH":"$HOME/.pub-cache/bin"

  6. write on terminal: firebase -P #copyYourProjectId# init

  7. write on terminal: firebase logout

  8. write on terminal: firebase login

  9. write on terminal: dart pub global activate flutterfire_cli

    write on terminal: use --add #copyYourProjectId# (now using the project)

  10. write on terminal: flutterfire configure project=#pasteyourprojectid#

{#select ios android web or macos }

toyota Supra
  • 3,181
  • 4
  • 15
  • 19