4

I am trying to use the 'firebase' command from my Mac terminal to deploy firebase cloud functions using 'firebase deploy --only functions'. I just used this command a week or two ago when I updated my firebase-functions and firebase-tools to version 3.18.4 but now everytime I try to use the 'firebase' keyword to run a command it says -bash: firebase: command not found. When I run npm -g list I see that I have firebase, firebase-tools and more in that list.

I've tried running 'npm install -g firebase-tools` but it still doesn't work. Also I tried what is recommended in this question

but still not working. Any advice would be great, thanks

MikeG
  • 3,745
  • 1
  • 29
  • 51
  • Did you try completely uninstalling `firebase-tools` (both locally and globally) and then reinstalling? – Frank van Puffelen May 11 '18 at 01:15
  • did you maybe install "npm install -g firebase tools" instead of "npm install -g firebase-tools" Note the missing dash. – Ronnie Royston May 11 '18 at 01:40
  • try to locate the path to the firebase command installed and verify that path in $PATH. – ntshetty May 11 '18 at 01:52
  • I did try uninstalling and then reinstalling and that didnt work. I also made sure to use the dash ie. `firebase-tools`. @ThiruShetty how do i locate the the path to the firebase command? – MikeG May 11 '18 at 15:15
  • I fixed the issue it was dumb on my part. After following the answer to the question I linked i forgot to acivate the changes to my bash profile by using `source ~/.bash_profile`. Once i did that the `firebase` command is now recognized. – MikeG May 11 '18 at 15:21

4 Answers4

4

First I ran npm get prefix which should output something like /Users/username/.npm-packages. Then I had to add the following to my $PATH variable

export PATH="/Users/username/.npm-packages/bin:$PATH" Note the extra /bin (after the result of npm get prefix)

And I also added export PATH="/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH$

Then you must activate the changes to your bash_profile by running source ~/.bash_profile

Once I did this the firebase command is again globally recognized

MikeG
  • 3,745
  • 1
  • 29
  • 51
3

Try the following in your terminal:

curl -sL https://firebase.tools | bash

This will check the OS of your machine and then install everything else automatically and properly.

The command is from the official Firebase Documentation.

1

I've just fallen into the same issue. My case was in different node versions a) when installing firebase globally, b) when using it during next session. I'm using nvm and my default was node v10, but I installed firebase on node v12. So after restart I got node v10. When I realised it, I switched nvm default from v10 to v12:

$ nvm alias default v12.13.1

And firebase started working.

dhilt
  • 18,707
  • 8
  • 70
  • 85
0

For those who use yarn instead of npm to manage global packages, yarn seems to place binaries in isolated directory as symbolic links. In my case, I did yarn bin to look for where binaries are, turned out it is $HOME/.config/yarn/global/node_modules/.bin. So, I set it to .bashrc. Now it's working.

minagawah
  • 95
  • 2
  • 9