Mac -bash:节点:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30467281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mac -bash: node: command not found
提问by Ronny vdb
I am having problems running node.js from the terminal.
我在终端运行 node.js 时遇到问题。
I have run the node.js installer for mac, but when I try to use the node command in the terminal, I get the following error:
我已经为 mac 运行了 node.js 安装程序,但是当我尝试在终端中使用 node 命令时,出现以下错误:
-bash: node: command not found
I have been trying to look for a solution but all the suggestions I found, dont help
我一直在寻找解决方案,但我找到的所有建议都无济于事
In the folder /usr/local/bin I have node and npm, but even when I navigate to the folder and run node, I still get the same error. I don't understand why this is happening, because I can see that node exists in the folder.
在文件夹 /usr/local/bin 中,我有 node 和 npm,但即使我导航到该文件夹并运行 node,我仍然遇到相同的错误。我不明白为什么会这样,因为我可以看到文件夹中存在该节点。
I also tried to edit the .bash_profile by adding /usr/local/bin but that didn't resolve the issue either
我还尝试通过添加 /usr/local/bin 来编辑 .bash_profile 但这也没有解决问题
Any suggestions would be greatly appreciated! TIA!
任何建议将不胜感激!蒂亚!
采纳答案by Ronny vdb
I found the cause of the problem.
我找到了问题的原因。
I had edited the .bash_profile to add the path to JAVA but I did not end it with a colon (:) so it ended up combining the path to JAVA with /usr/local/bin
我编辑了 .bash_profile 以添加到 JAVA 的路径,但我没有以冒号 (:) 结束它,所以它最终将 JAVA 的路径与 /usr/local/bin 结合起来
Once I added the colon, everything started working
一旦我添加了冒号,一切都开始工作了
回答by Prutha Nagrikar
brew search node
then brew install node@version
, example:
然后brew install node@version
,例如:
brew install node@8
brew link node@8
node --version
Still getting node not found, try this:
仍然找不到节点,试试这个:
brew link --overwrite --force node@8
回答by Naseer
回答by Shamal Perera
If you have already installed node and still doesn't work, you might try running brew link node
. You could create a force link if an error occurs while creating the link. brew link --overwrite node
如果您已经安装了 node 并且仍然无法运行,您可以尝试运行brew link node
. 如果在创建链接时发生错误,您可以创建强制链接。brew link --overwrite node