brew 安装 npm "npm: command not found"

brew install npm "npm: command not found"

我使用 brew install node 安装了节点,当我使用 node -v 时,我得到了关注 v5.0.0。但是,当我尝试 运行 npm 命令时,我得到 npm: command not found

我已经尝试 运行 brew install npm,但是我只收到以下回复 node-5.0.0 already installed

node 也返回命令未找到,但我已通过 运行ning brew link node 修复,但 npm 似乎仍然无法正常工作。

我该如何解决这个问题?

尝试运行

$ brew postinstall node

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

$ 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 上的 hostname/computername 中使用了西里尔(非拉丁)字符。这就是问题所在。在我更改此设置并使用 Homebrew 重新安装 node/npm 后,一切正常。 2017年没有utf8? :/

和你一样的问题,我解决了:

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

运行:echo 'export PATH="/opt/homebrew/opt/node@16/bin:$PATH"' >> ~/.zshrc 应该可以,将 node@16 更改为 node 或您刚刚安装的任何版本。