我在macOS上安装了节点
brew install node
执行此操作后,节点已正确安装:
$ node -v
v8.4.0
但是正在运行
$ npm -v
给了我-bash: /usr/local/bin/npm: No such file or directory
现在通过brew安装节点的方式是什么?
brew install node
默认使用--without-npm
答案 0 :(得分:2)
我遇到了同样的问题。我运行$ brew doctor
以确保首先链接节点。然后我跑了
$ brew postinstall node
$ npm -v
现在应显示版本号。
答案 1 :(得分:1)
我也遇到了类似的问题。我的问题是我还没有
~/.bash_profile
file in place因此无法将我的bash命令实际链接到npm
。
答案 2 :(得分:0)
不要使用Homebrew来安装节点。
我喜欢Node Version Manager (NVM),还有n。这些是Mac上节点的更好选项,以避免certain。 issues。 later。此外,它避免了这个问题,因为这些节点版本包括npm
。
注意,您可以通过Homebrew安装nvm
和n
。 (brew install nvm
或brew install n
)。