31

I am in a bizarre problem, I just updated my Node.js and NPM at the date of 01-Feb-2019. And used the following command-

npm install -g firebase-tools

to install the Firebase CLI

Then on typing either of the code below

firebase login

or

firebase init

it is showing the following error

'firebase' is not recognized as an internal or external command, operable program or batch file.

Please help me. It has already consumed my two days.

21 Answers21

26

Ok. First of all, Bizarre problem has some bizarre solution. Uninstall your node js and NPM completely. Then reinstall it, and check, whether it works or not. Best of Luck

KAPIL SHARMA
  • 395
  • 3
  • 8
  • 3
    I can't believe, this kinda problem can be arise with the solution you told. Hey thanks buddy, it took my 3 days but finally I am happy that I got a solution. Thanks again –  Feb 02 '19 at 04:49
  • Only reinstalling NodeJs solved for me! Thanks. – Pablo Chvx May 27 '21 at 01:22
20

npm install -g firebase-tools -f

Using -f for force install again. This work for me

S.Anu
  • 211
  • 2
  • 3
10

add to .bash_profile export PATH="$PATH:/usr/local/bin" and run

npm install -g firebase-tools

this worked for me

Mehmet Ali Bayram
  • 5,904
  • 2
  • 20
  • 25
7

If you are using MS Windows:

  1. Open Start Menu or press Win button on your keyboard.
  2. Type "variables".
  3. Click on "Edit the system environment variables"
  4. Click on "Environment Variables..." button.
  5. In the "System variables" list select "Path" and click on the "Edit..." button under the list.
  6. In the "Edit environment variable" dialog click on the "Browse..." button.
  7. Navigate to the c:\users\<yourusername>\AppData\Roaming\ dir and select the "npm" sub-dir, then click "OK".
  8. In the "Edit environment variable" dialog click "OK".
  9. In the "Environment Variables" dialog click on "OK".

For the Linux users:

  1. Navigate to the home_dir.
  2. Edit the hidden ".bash_profile" file.
  3. Add line with following text "export PATH="$PATH:/usr/local/bin".
Ahmed Ashour
  • 4,462
  • 10
  • 33
  • 49
technik
  • 819
  • 9
  • 15
4

Navigate to the firebase directory and call it out on the cmd.

  • run cmd as admin
  • cd C:\users\yourusername\AppData\Roaming\npm
  • firebase.cmd login or firebase login
  • firebase will prompt a google login after which the issue should be resolved.

There you go. above steps are all commands goes to your command prompt.

3

After running npm install -g firebase-tools, go to C:\usr\local. You will see Firebase files.

  1. Copy this path C:\usr\local to the clipboard.
  2. Open the Start Menu and search for Edit the System Environment Variables or simply env.
  3. Select the environment variables option that appears.
  4. Find the PATH variable under the system environment variables (lower section).
  5. Select PATH and click Edit
  6. Add C:\user\local to the beginning of the path.
  7. Add %APPDATA%\npm if it doesn't exist.
  8. Click OK to each of the windows until they're all closed.

After this, open a Windows command prompt and run firebase --version.

Robert Dean
  • 687
  • 7
  • 14
Pratyush
  • 31
  • 2
1

Make sure you are running command line as an administer.

Gabe
  • 3,405
  • 2
  • 21
  • 45
1

Make sure you run the CMD in administrator mode. Also once you have run npm install -g firebase-tools commands close the CMD prompt and reopen again. If this doesn't work uninstall node and reinstall it again. It requires your node version to be a minimum version to support firebase.

Tharindu Jayasinghe
  • 1,401
  • 1
  • 11
  • 12
1

After installing

$ npm install -g firebase-tools

Note the directory where it installed What I did was locate the directory where firebase was installed. In my case C:\usr\local then I copied the three firebase files. I also went into the node_modules folder and copied the firebase tools folder. Then I went to my app directory in file manager and pasted the firebase files, then created a new node_modules folder and pasted the firebase-tools folder.

Now go to your cmd and run

$ firebase init

It should work

D. Schreier
  • 1,563
  • 1
  • 21
  • 32
Alalade Samuel
  • 447
  • 4
  • 3
1

My solution is to use Firebase CLI binary for Windows:

  1. Download CLI: https://firebase.google.com/docs/cli#install-cli-windows
  2. Run CLI, go to the project directory (cd 'your app path'). By the way, you may see the version: run "firebase --version" for that
  3. Run "firebase login" with Firebase CLI
  4. Run "firebase init" with Firebase CLI
1

Add this to the environment variable:-

C:\Users\<user>\AppData\Roaming\npm\firebase

it will allow firebase commands in ps/cmd

i dont think : C:\Users<user>\AppData\Roaming\npm\ now works.

Saud Ahmed
  • 29
  • 5
  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Sep 06 '21 at 06:35
0

For peeps like me who were unable to get rid of this problem after trying everything suggested above. I know it is late but I Fixed it by changing the location for installing my packages. I ran the command "npm config get prefix" in cmd and I found out that my default location for node_modules installation had been changed. so I set it back to default by "npm config set prefix "C:\Users\your_PC_Name\AppData\Roaming\npm". After that I used "npm install -g firebase-tools" again

My firebase package was installed. I was relieved to see firebase.cmd file in npm folder. Earlier I had tried every thing like uninstalling node.js and deleting npm and npm cache folders but all those methods didn't work for me.

Cannot get "npm install -g" to work on any packages (AppData/Roaming/npm always empty) this discussion worked for me only.

0

all of the Simple and Quick solution is here... step1): just go to C:\Users\your-user-name\AppData\Roaming\npm step2): copy the path of this "npm"-folder step3): now go to start and type "env" and select first-option then step4): now paste that path in "paths"-option by clicking on "edit"-button step5): then click on "ok" and restart your pc

Ajay jangid
  • 301
  • 3
  • 4
0

I had similar issue in MAC. Terminal was giving me command not found message on running "firebase --version". So, I tried to reinstall the firebase with the command: "sudo npm i g firebase-tools" but it again errored out stating that the installed firebase binary file is corrupted.

Solution: STEP 1. Provide read, write and execute access with "sudo chmod a+rwx configstore" cmd to the path :

"/Users//.config/configstore/"

STEP 2. Run following command to update firebase:

sudo curl -sL firebase.tools | upgrade=true bash

0

Add C:\users\yourusername\AppData\Roaming\npm to your environment variable PATH.

Yassir Khaldi
  • 1,002
  • 1
  • 12
  • 22
0

For anyone still fighting this problem try to add the system environment path not to a user's environment.

0

https://github.com/firebase/firebase-tools/issues/46#issuecomment-615534999

  1. Run your cmd from C:\Windows\System32\cmd.exe or type this in your file path and hit Enter
  2. Just reinstall firebas-tools {npm i firebase-tools -g} globally
  3. Restart your computer its work for me good luck
AEM
  • 1,284
  • 6
  • 17
  • 26
Skull
  • 1
  • 2
0

Simple answer to this question is-
1.npm install firebase command in terminal window.
2.Add firebase scripts in your editor that you use.
3.set the Path in the environment system variable.

I think it will be able solve your problem...

0

1.After installing firebase globally via npm i -g firebase-tools

2.simply run all your firebase commands from the node command-line tool, it instantly worked for me.

3.To access the node command line, simply go to the start menu on windows and type "node.js command prompt"

Mohammad Hosseini
  • 1,283
  • 11
  • 29
Fortun
  • 9
  • 1
0

My solution was that my project was on partition F: somedirectory/app, and when I moved it on partition C: Users/username/Documents/app It worked!

I tried everything mentioned and more, lost couple of hours.

So moving on partition where I installed: npm install -g firebase-tools then: firebase login, then: firebase init

Marine Le Borgne
  • 976
  • 2
  • 10
  • 37
0

npx firebase <your command>