我试图修复运行 npm 时必须使用 sudo 的错误。我盲目地按照链接卸载节点,代码来自这个 要点
运行命令后,我尝试使用 brew: brew install node
重新安装它。这给了我以下错误:
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable.
You can try again using:
brew link node
尝试运行 brew link node
,我得到:
Linking /usr/local/Cellar/node/5.4.0...
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.
然后当我写 brew install npm
时,我得到:
Warning: node-5.4.0 already installed, it's just not linked
当我写 npm -v
我得到:
env: node: No such file or directory
关于如何解决这个问题的任何想法?
原文由 Ela 发布,翻译遵循 CC BY-SA 4.0 许可协议
我设法通过首先运行
sudo chown -R $USER /usr/local
并使用brew link node
来解决这个问题。现在我已经正确安装了节点。