0

I have been having trouble installing firebase command line tools. I am following the guide at: https://www.firebase.com/docs/hosting/command-line-tool.html. I have run the initial command into my terminal: npm install -g firebase-tools. Once I run: firebase init in the root of my directory, I get the following error:

-bash: firebase: command not found

I have looked at guides how to manually modify my bash profile, but can not figure out how to do so... Shouldn't my bash .bash_profile automatically get modified when I run a global command?? Any help would be appreciated. I just need my firebase commands to work in the terminal, and why the global command won't register in my bash profile?

Carl Sverre
  • 1,139
  • 10
  • 19
K Ghumaan
  • 97
  • 7

1 Answers1

0

When you run npm install -g firebase it tries to install the firebase library and associated binaries into a system-wide location. You can determine where this location is by running npm prefix -g. In order for the firebase binary to be available to your bash session, the bin directory inside your global npm prefix must be on your path.

In Bash, an easy way to add a directory to your PATH is by modifying the .bashrc file in your home directory. Appending a line like so will add the global npm bin directory to your current PATH:

PATH="$(npm prefix -g)/bin:$PATH"

Once you have modified your PATH variable either open a new terminal session or run export PATH="$(npm prefix -g)/bin:$PATH" for the change to immediately take effect.

If ~/.bashrc is not being sourced on your machine, an easy fix is adding the following line to your ~/.bash_profile file:

source "$HOME/.bashrc"

Carl Sverre
  • 1,139
  • 10
  • 19
  • If my terminal states ~/.bashrc does not exist, should I create a blank file and add PATH="$(npm prefix -g)/bin:$PATH" to it? I have already added 'source "$HOME/.bashrc" ' to my bash profile, but that alone is not doing much – K Ghumaan Aug 09 '16 at 14:22
  • Yup, add a new file called `.bashrc` with that line in it. Then start a new terminal session. – Carl Sverre Aug 10 '16 at 02:53