11

I'm just trying to do a simple set-up for hosting on firebase. I'm following the instructions at (https://www.firebase.com/docs/hosting/guide/deploying.html) but I'm missing something because I keep getting an error of:

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

What I've done:

  1. Installed nodejs.
  2. Set PATH = to C:\Program Files\nodejs; via control Panel
  3. in cmd: cd C:\Program Files\nodejs
  4. npm install -g firebase-tools
  5. changed directory to folder with my html files
  6. tried running both firebase app init and firebase init neither of which work and give me the same error

screenshot of cmd

Alexsandra Guerra
  • 1,625
  • 4
  • 17
  • 19

5 Answers5

21

I had this exact same error. I fixed it by changing the path variable to include firebase.

Try finding firebase.cmd on Windows through C:\Users\myname\AppData\Roaming\npm. I couldn't find firebase.exe, which is where I got confused. Looking at your screenshot, I can see where the path is saved.

Just search for the firebase.cmd and add it to your %PATH% C:\Users\myname\AppData\Roaming\npm. Then restart and try again: firebase should be a valid command

Sorry this is a year late and hope this helps someone.

Script Kitty
  • 1,737
  • 5
  • 27
  • 47
  • how do I add something to my %PATH%? – J.Ko Nov 07 '18 at 21:14
  • @J.Ko Control panel >> type 'env' in search >> Edit Environment variables for your account >> Path >> Add your path – Linda Nov 08 '18 at 05:49
  • from where I find firebase,cmd? – Muhammad Umer Mar 23 '19 at 03:34
  • AppData is not a file in my user directory? – Gabe Jun 01 '20 at 19:43
  • 1
    AppData is a hidden directory inside the C:\Users\\ folder. Change the folder settings to show the hidden items and then once you have that complete path, open the cmd as administrator and type set PATH=%PATH%;C:\Users\\AppData\Roaming\npm hope this helps someone. – Saurabh Jan 23 '21 at 03:00
2

The easiest way is to run

npm install -g firebase-tools .
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Md omer arafat
  • 398
  • 7
  • 10
1

According to Script Kitty's answer, for windows solution only:

You are probably missing npm in your path. You can check it by echo %PATH% to make sure. Thus, open Environmental variables > system variables > path

see if you could not find C:\Users\yourusername\AppData\Roaming\npm there.

if not, add it following this link. Or simply add your npm path there.

DragonKnight
  • 1,740
  • 2
  • 22
  • 35
1

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

TT.
  • 15,774
  • 6
  • 47
  • 88
Ajay jangid
  • 711
  • 9
  • 9
0

open a terminal or cmd run as administrator mode

or

If you are using MS Windows:

Open Start Menu or press Win button on your keyboard.

Type "variables".

Click on "Edit the system environment variables"

Click on "Environment Variables..." button.

In the "System variables" list select "Path" and click on the "Edit..." button under the list. In the "Edit environment variable" dialog click on the "Browse..." button.

Navigate to the "c:\users\AppData\Roaming" dir and select the "npm" sub-dir, then click "OK".

In the "Edit environment variable" dialog click "OK".

In the "Environment Variables" dialog click on "OK".

For the Linux users:

Navigate to the home_dir.

Edit the hidden ".bash_profile" file.

Add line with following text "export PATH="$PATH:/usr/local/bin".

Vijay
  • 275
  • 2
  • 11