Firebase-tools: Can't access firebase command after install

Created on 13 Apr 2015  ·  48Comments  ·  Source: firebase/firebase-tools

I'm able to run the global install of firebase-tools:
$npm install -g firebase-tools
but then I try to run:
$ firebase init
and I get the error:

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

I would really appreciate anyone's help! I've also posted this on stackoverflow:
http://stackoverflow.com/q/29531235/4342441?stw=2

Most helpful comment

@tejasrsuthar
navigate to the firebase directory and call it out on the cmd. so
1.run cmd as admin

  1. cd C:users\yourusernameAppData\Roaming\npm
  2. firebase.cmd login
    or firebase login
    there you go. above steps are all commands goes to your command prompt.

All 48 comments

@alexsandracodes Apologies for the delayed reply. What can you tell us about the platform that you're running on (Win, OSX, Linux w/ version) in addition to the environment (Node and NPM versions)?

@alexsandracodes From the StackOverflow, it looks like you're on Windows. If you've solved this, could you let us know how you resolved it? If not, could you reach out to me at [email protected]?

Hey Robert! Thanks a lot for the response. Sorry I didn't notice it before. It wasn't actually an issue with firebase, it was an npm install issue. I got it figured out now. :)

@alexsandracodes Ok, great! I'll close this issue out. Out of curiosity, is there anything that might be useful for us to document, in case others run into the issue?

Yeah, definitely. I'm glad you ask. From my perspective, Firebase is a great tool for those who are not shy to pick up programming, but who are not necessarily knowledgeable of all the ins-and-outs. I've basically described myself, someone who wants a robust and easy to use tool that they can use without having to learn back-end programming in-depth. I feel like that aligns with Firebase's vision. That being said...

I like the clear and concise format of the guides, but there are cases where things are too simplified, and they don't actually work out for the user as simply as shown in the guide. Take for example, the hosting/deploy guide on firebase (https://www.firebase.com/docs/hosting/guide/deploying.html). It quickly tells you to install node.js and then run '$ npm install -g firebase-tools', and then '$ firebase init'. In theory, this processes should have been very easy for me, but instead it took a lot of times, weeks, to figure out what was going on behind the scenes with node.js and it's npm installer. It would be helpful if you could reference some guides for node.js and npm installer so that readers who are not familiar with the software and look it up. Basically, what I'm trying to say is, for the newbie who is picking up web dev for the first time, giving them a bigger picture of what the dependencies are (other software requirements) and some of the issues that they might occur along the way, would be helpful.

Also, it would be great if there was an option to export your documentation as a PDF or even a basic text file. As I recall, documentation for Firebase documentation is only accessable via the web.

@alexsandracodes Thanks for the feedback! That's really helpful, and I'll pass this along to the rest of the team.

so how did you fix it @alexsandracodes ????? same prob ty.

kindly tell me how did you resolve this problem i have install npm tool but i could not understand what is npm issue

Today I also got the same issue. @alexsandracodes would you please kindly let us know what steps did you follow in order to fix that issue? Thanks.

@tejasrsuthar
navigate to the firebase directory and call it out on the cmd. so
1.run cmd as admin

  1. cd C:users\yourusernameAppData\Roaming\npm
  2. firebase.cmd login
    or firebase login
    there you go. above steps are all commands goes to your command prompt.

Thank you so much @flyingsriracha it worked.

Ahh this causes me so much pain! I had it working the very first time I installed firebase and ran login, deploy, etc.

After closing the PowerShell window I was using, I haven't been able to access firebase commands in any CLI (cmd, Git Bash, PowerShell or all as administrator). I have done the steps outlined by @flyingsriracha however it only gets me to 'login'. I can't do any other firebase commands in any other directory.

Please help! I've also installed latest firebase tools several times in each CLI with no luck (they install, I restarted and I still cannot access firebase commands). I am on Win 10.

Thanks!

And within 8 minutes of posting I did it! Albeit ... not as I expected.

To use firebase at the moment, I must list the FULL directory path with each command. Meaning "firebase init" is now "C:Users\nameAppData\Roaming\npm\firebase.cmd init"

Now I just realised, that's what you said @flyingsriracha 💃

like the above, I was only able to run it by typing the full path, ie; C:Users\nameAppData\Roaming\npm\firebase init
Why is it like this when it is supposed to be easier by simply typing firebase init from within the project folder? And how can we fix things so that it is like this? Is that possible? Running Windows 7.

SOLUTION
For those still having trouble, seems to be for me that where npm installs its packages has been lost as an environment variable.
If the package has been installed globally, it's normally in C:\Users\"yourname"\AppData\Roaming\npm
If you add that to your %PATH%, open a new cmd window, and you should be good to go.

Cheers @flyingsriracha those were exactly the steps I needed

None of this works. What do you have to do to get this running? What a joke.

This worked for me:

  1. Open cmd and cd C:\Program Files\nodejs
  2. npm install -g firebase-tools
  3. Restart your computer
  4. Open cmd and check firebase --version.

in cmd to check if it is installed and its version:
npm firebase -version

Add this path to Windows 10 Advance Settings "Environment Variables" PATH and then restart your system.
%USERPROFILE%AppData\Roaming\npm\firebase;

Try to reinstall NodeJS that fixed this problem for me

Building off of what @danielcrowley said, make sure you EDIT your Path variable. Put a comma at the end and then paste the path, otherwise, you'll do what I just did and delete whatever else was in your path and overwrite it with your new npm path.

Whoops :(

@danielcrowley it still not working for me

Thank you so much @flyingsriracha it worked.

@vedhaperi thank you so much ..

@vuabid has mentioned the way to fix the long path problem, but I will make it detail instruction for others:
(I'm using win 10)

  1. Open File Explorer (or simply press WindowButton + E).
  2. Right click on "This PC" => properties
  3. Look for "Advanced system settings" on the left side => click on that and it will open a popup
  4. Choose "Advanced" tab => Click on button "Environment Variables ..."
  5. In the "System variables" segment, look for variable "Path" => choose and click on "Edit" button
  6. Click "New" button and paste in the new line with this link:
    "C:Users{yourUsername}AppData\Roaming\npm"
    (Check the link in your PC for concise path)
    => Press Enter => OK => OK => OK
  7. Now you can open a new cmd, type in "firebase --version" and you will see the version of your firebase

bless you! @PercyPham

This alone worked for me on Windows 10 system
npm install -g firebase-tools
Before trying this I used :
npm i g firebase-tools (just g instead of -g) and it was not working

On Windows 10, Press Win+I to open the system settings dialog. In the search box type "environment" Choose "Edit Environment variables for your account"
Then add %USERPROFILE%AppDataAppData\Roaming\npm to your Path environment variable.

I think the main issue most people have is that when you navigate to C:Users\USERNAME\appdata\Roaming\npm
"firebase" file and "firebase.cmd" file tend to be missing. I believe a re-install and reboot should fix it

add env variable in path can fix it. and restart cmd. if you use some terminal emulator like fluent terminal, it may not recognize, just have a try at another one, like hyper terminal, or cmd, powershell

@danielcrowley Thanks. Adding a globally installed package to the path of env variables helps.

C:users\yourusernameAppData\Roaming\npm

Alternatively, you can add this to your PATH using environment variables in windows.

Add this path to Windows 10 Advance Settings "Environment Variables" PATH and then restart your system.
%USERPROFILE%AppData\Roaming\npm\firebase;

Thank you very much. That worked for me.

This worked for me "npm install -g firebase-tools"

Some time when you install node it will update %PATH% for user environment variable but you have to add "C:UsersusernameAppData\Roaming\npm" path in %PATH% of system environment variable and then after restart you terminal or cmd and try "firebase init".

I've tried changing the path variable, running from the npm directory, restarting, and everything else listed here. Still no luck.

It worked fine on another PC though.

The "firebase login" command is not working for me.What do i do?

likewise me, tried all the options stated here all to no avail

I tried all the methods but I am still getting the same error.
firebase: command not found
Please help?

For people who try all the methods and still getting the same error, the following steps works for me:
1) run npm install -g firebase-tools
2) In C:** you will see a folder name **usr. In the usr folder, copy the local folder and paste it in the C:Users{PCName}AppData\Roaming\npm.
3) Rename the local with firebase.
4) Enter in environment variables -> Path ->Edit -> New -> C:Users{PCName}AppData\Roaming\npm\firebase -> OK -> OK -> OK

And restart the PC

After restart, for testing if it work, enter in cmd and write firebase --version

@tejasrsuthar
navigate to the firebase directory and call it out on the cmd. so
1.run cmd as admin

  1. cd C:users\yourusernameAppData\Roaming\npm
  2. firebase.cmd login
    or firebase login
    there you go. above steps are all commands goes to your command prompt.

It is also not working!

Thankyou @flyingsriracha that worked for me

I have this problem, tried all the above steps, have the correct environment variables and no luck.

I see that firebase is contained within /users/appdata/roaming/npm/node_modules/firebase

How far down the directory tree should the Path variable be set? only to /npm ?

I'm able to run the global install of firebase-tools:
$npm install -g firebase-tools
but then I try to run:
$ firebase init
and I get the error:

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

I would really appreciate anyone's help! I've also posted this on stackoverflow:
http://stackoverflow.com/q/29531235/4342441?stw=2

This is the answer!!
Set-ExecutionPolicy RemoteSigned

I have this problem, tried all the above steps, have the correct environment variables and no luck.

I see that firebase is contained within /users/appdata/roaming/npm/node_modules/firebase

How far down the directory tree should the Path variable be set? only to /npm ?

Hii!

Just Run this command in your working directory.
Set-ExecutionPolicy RemoteSigned

There are now an abundance of troubleshooting steps and solutions offered here. Locking this issue as further "me too" discussions aren't going to be findable or resolvable at this point. If you try the following steps and still have problems, file a separate issue with a minimal, complete, verifiable repro of the problem (logs, screenshots, steps, version info, os info, et al) that can be used for troubleshooting.

Ways to install the CLI (doc):
auto install script: curl -sL https://firebase.tools | bash
standalone binary: download here
npm version: npm install -g firebase-tools

Where the CLI executable is usually stored
Mac: /users/appdata/roaming/npm/node_modules/firebase
Windows: C:\users\yourusername\AppData\Roaming\npm or %USERPROFILE%\AppData\AppData\Roaming\npm

Potential solutions if your OS can't find the command

  1. If running env (mac) or echo %PATH% (windows) doesn't show the path to your CLI executable add it to your PATH environment variable (on windows: WIN+L to open settings, search for environment).

  2. Try running Set-ExecutionPolicy RemoteSigned so post

  3. Run it manually (just a temporary workaround, should not be necessary)

    1. run cmd as admin
    2. cd C:\users\yourusername\AppData\Roaming\npm
    3. firebase.cmd login or firebase login

After all solutions, you need to close the terminal / command prompt and restart it! Some users had to restart their computers before the changes took effect, but it's unclear if that's actually necessary.

Was this page helpful?
0 / 5 - 0 ratings