4

I am following a tutorial on Ionic Angular and it has come to the point where the instructor is having me publish my code to Firebase Hosting. First I used NPM to install the Firebase CLI. Then I was instructed to use the firebase init command. The issue is that the CLI doesn't seem to recognize the current directory that is selected in my terminal.

I run: cd /Users/MyUserName/myProjectsFolder/myProject/ Then I run firebase init and it displays:

You're about to initialize a Firebase project in this directory:

/Users/MyUserName

When I would expect it to read:

You're about to initialize a Firebase project in this directory:

/Users/MyUserName/myProjectsFolder/myProject

A little bit of googling found this page: https://firebase.google.com/docs/cli/

Which includes this passage:

To initialize a new project directory, change directories in the terminal to your desired project directory and run: firebase init

Based on this I would expect the steps I took to work.

I am confused. Has anyone ever run into this behavior? Can anyone think of a way to get the CLI to function as expected?

Thanks.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
WillD
  • 5,170
  • 6
  • 27
  • 56

6 Answers6

16
  1. Got to folder:

    /Users/Username/

  2. Search for a file with name of firebase.json and Delete it.

  3. Reinstall firebase tool with this command (--unsafeper- to avoid permissions error messages & use sudo):

    $ sudo npm install --unsafeper- -g firebase-tools

  4. Then, go to your pubilc folder (you have to create one) which contains your HTML, JS, images and CSS files and use this command:

    $ sudo firebase init

    $ sudo firebase deploy

  5. The reset is easy and as mentioned in the firebase docs:

https://firebase.google.com/docs/hosting/quickstart

CrownFord
  • 709
  • 5
  • 15
2

The reason is that you must have initiliazed a project in some parent directory (of this myProject folder) in the past. Somehow firebase sees that project in that directory rather than initializing a new project in the current path.

Solution: Check the parent directories of the path where you want to initialize a firebase project now. Delete / Move the firebase files from that folder and then you should be able to initialize a project in the current directory.

For example:

I also faced the same problem. I was trying to initialize a project in this path:

D:\Work\Projects\myProject

But somehow it always got initialized in this path:

D:\Work

After some searching it turned out that the reason was that I had initialized a project in D:\Work directory. I moved those files to another folder and that solved the problem.

Nafees Tariq
  • 131
  • 2
  • 4
1

I was also facing this problem and windows not able to recognize the firebase. I don't know the exact reason why it was behaving in such a manner but it solved the problem.

1) I installed the firebase-tools using a command on command prompt

npm install -g firebase-tools

and it didn't work. 2) I restarted the machine. 3) then again I executed the same command from step 1) npm install -g firebase-tools and it worked.

ironman
  • 946
  • 14
  • 23
1

Was trying to do this and discovered a command that allows "firebase" as a command.curl -sL https://firebase.tools | bash This will allow $ firebase login and $ firebase init to work.

Blake
  • 13
  • 3
0

one you should write that in cmd

  firebase login

if the cmd response " Already logged in as hello@example.com" you should to regenerate the authentication of this email

-1

I was facing the same issue. After checking the log I figured out that the Authentication token was expired from my firebase cli login session. So I logged out and Logged-In again to the firebase cli using Firebase logout And firebase login command. Problem solved.

To check out your issue go to firebase log using firebase-debug.log command. And take required steps.