brew安装npm“npm:command not found”

我已经使用brew install node ,当我使用node -v我得到了v5.0.0 。 但是,当我尝试运行npm命令,我得到npm: command not found

我试着运行brew install npm ,但是我刚刚brew install npm了以下响应node-5.0.0 already installed

它发生了节点也返回命令没有find,但我通过运行brew link node ,但是npm仍然似乎不工作。

我该如何解决这个问题?

您需要确保您的$NODE_PATH环境variables已设置:

 # Add this to your ~/.bash_profile file: export NODE_PATH="/usr/local/lib/node_modules" 

您也可以尝试以下方法:

运行以下命令删除所有现有的全局npm模块,卸载节点&npm,重新安装具有正确默认值的节点,安装npm作为它自己的pacakge,并configuration要安装的全局npm模块的位置。

rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

Kudus到: https ://gist.github.com/DanHerbert/9520689

我遇到了同样的问题。 在网上search和阅读不同的东西之后,对我有用的是:

 $ brew postinstall node 

但是,请先执行:

 $ brew doctor 

并按照说明那里第一,就像你提到的问题中的评论。

尝试以下操作:

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

我在我的主机名/计算机名在Mac上使用西里尔(非拉丁)字符。 这就是问题所在。 我改变了这一点后,用Homebrew重新安装node / npm,一切正常。 2017年没有utf8? :/