现在用brew通过npm安装节点的方法是什么

时间:2017-08-18 15:02:45

标签: node.js macos npm homebrew

我在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

3 个答案:

答案 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上节点的更好选项,以避免certainissueslater。此外,它避免了这个问题,因为这些节点版本包括npm

注意,您可以通过Homebrew安装nvmn。 (brew install nvmbrew install n)。