Firebase command not found days after having already successfully used it

[亡魂溺海] 提交于 2021-01-02 20:40:38

问题


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


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/50283393/firebase-command-not-found-days-after-having-already-successfully-used-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!