brew install npm “npm: command not found”

2020-05-15 11:50发布

I've installed node using brew install node and when I use the node -v I get following v5.0.0. However when I try to run the npm command I get npm: command not found.

I've tried to run brew install npm, however I just got following response 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.

How can I resolve this problem?

5条回答
男人必须洒脱
2楼-- · 2020-05-15 12:34

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.

查看更多
Bombasti
3楼-- · 2020-05-15 12:39

Try the following:

$ brew update
$ brew uninstall node
$ brew install node
$ sudo chown -R YouComputerName /usr/local/lib/node_modules/
$ brew postinstall node

查看更多
forever°为你锁心
4楼-- · 2020-05-15 12:49

Try running

$ brew postinstall node
查看更多
祖国的老花朵
5楼-- · 2020-05-15 12:50

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? :/

查看更多
放我归山
6楼-- · 2020-05-15 12:53

the same problem with you, I fixed by:

/usr/local/lib/node_modules/npm/bin/npm-cli.js i -g npm

查看更多
登录 后发表回答