40

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.

27 Answers27

33

npm install -g firebase-tools -f

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

S.Anu
  • 341
  • 3
  • 3
30

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
  • 437
  • 4
  • 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
17

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
  • 5,179
  • 10
  • 35
  • 56
technik
  • 1,009
  • 11
  • 17
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
  • 7,222
  • 2
  • 22
  • 27
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 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,700
  • 1
  • 22
  • 34
Alalade Samuel
  • 574
  • 5
  • 6
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
  • 685
  • 5
  • 16
Pratyush
  • 31
  • 2
2

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,649
  • 1
  • 16
  • 31
Fortun
  • 37
  • 3
2

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
2

My firebase command stopped working after I uninstalled node and shifted to last version of node with nvm.

what worked for me is adding C:\Program Files (x86)\Nodist\bin to system environment variables

To do so here are the instructions:

  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. Add ;C:\Program Files (x86)\Nodist\bin; to the end of the list
  7. Then click "OK"
  8. In the "Edit environment variable" dialog click "OK".
  9. In the "Environment Variables" dialog click on "OK".
umermon
  • 21
  • 1
1

Make sure you are running command line as an administer.

Gabe
  • 5,643
  • 3
  • 26
  • 54
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
  • 2,821
  • 1
  • 15
  • 15
1

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.

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
  • 65
  • 6
1

I was struggling with this same issue for a few days and had an issue where my NPM was installed in two different places for whatever reason.

I had an npm folder in C:\Users\<user>\AppData\Roaming\npm\ as well as C:\Users\<user>\npm\

Turns out the Firebase installation command installed all the needed files into the latter folder, while my Environment PATH was pointing to the first folder.

I changed my PATH variable to C:\Users\<user>\npm\ and ran the firebase installation again. After that everything started working fine.

If you havent checked the other answers about what PATH is, you can access it by typing env in the Windows search bar and from there click the Environment Variables button. Then double click the Path line under System variables to edit it. Remember to press OK to save any changes.

This is probably a rare edgecase, but maybe it will help someone.

liquardo
  • 91
  • 1
  • 10
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
  • 711
  • 9
  • 9
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,452
  • 1
  • 17
  • 30
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,354
  • 8
  • 20
  • 30
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

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
  • 1,036
  • 2
  • 11
  • 39
0

npx firebase <your command>

0

If you have similar problems like this

firebase : File C:\Users\<user-name>\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more em. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ firebase login
+ ~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

perhaps you can try to Ctrl + Click the C:\Users<user-name>\AppData\Roaming\npm\firebase.ps1

After that you'll see a new PowerShell Terminal and you can continue it.

Hope it's works

Rin
  • 1
  • 1
0

In my case it was necessary to add npm path C:\Users<username>\AppData\Roaming\npm in environment variables in system PATH variable

0

Try restarting your system. That worked for me

Basith P
  • 9
  • 3
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 07 '23 at 06:25
0

Using administrator cmd worked for me.

windows key

cmd

ctrl+shift+enter

npm install -g firebase-tools

MrBom
  • 23
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 18 '23 at 05:16