node.js brew install npm "npm: command not found"
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33575082/
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
brew install npm "npm: command not found"
提问by Peter Pik
I've installed node using brew install nodeand when I use the node -vI get following v5.0.0. However when I try to run the npmcommand I get npm: command not found.
我已经安装了节点brew install node,当我使用时,node -v我得到了以下v5.0.0. 但是,当我尝试运行npm命令时,我得到npm: command not found.
I've tried to run brew install npm, however I just got following response node-5.0.0 already installed.
我试图运行brew install npm,但是我只是得到了以下响应node-5.0.0 already installed。
It happened with node also returning command not found, but that I fixed by running brew link node, however npm still does not seem to work.
它发生在 node 也返回 command not found 的情况下,但我通过运行修复了它brew link node,但是 npm 似乎仍然不起作用。
How can I resolve this problem?
我该如何解决这个问题?
采纳答案by andlrc
Try running
尝试跑步
$ brew postinstall node
回答by mpavel
I encountered the same issue. After searching and reading different things online, what worked for me was:
我遇到了同样的问题。在网上搜索和阅读不同的东西后,对我有用的是:
$ brew postinstall node
However, first please do execute:
但是,首先请执行:
$ brew doctor
and follow the instructions there first, like the comment in your question mentions.
并首先按照那里的说明进行操作,就像您问题中提到的评论一样。
回答by dian.in
Try the following:
请尝试以下操作:
$ brew update$ brew uninstall node$ brew install node$ sudo chown -R YouComputerName /usr/local/lib/node_modules/$ brew postinstall node
$ brew update$ brew uninstall node$ brew install node$ sudo chown -R YouComputerName /usr/local/lib/node_modules/$ brew postinstall node
回答by zhulinpinyu
the same problem with you, I fixed by:
和你一样的问题,我通过以下方式解决:
/usr/local/lib/node_modules/npm/bin/npm-cli.js i -g npm
/usr/local/lib/node_modules/npm/bin/npm-cli.js i -g npm
回答by Tadej
I used cyrillic (non-latin) characters in my hostname/computername on mac. And that was the problem. After i changed this and reinstalled node/npm with Homebrew everything worked like normal. No utf8 in 2017? :/
我在 mac 上的主机名/计算机名中使用了西里尔文(非拉丁文)字符。这就是问题所在。在我更改此设置并使用 Homebrew 重新安装 node/npm 后,一切正常。2017年没有utf8?:/

