最近发现了homebrew的诸般便利,并且发现自己手动更新node和npm总是不是网络有问题就是什么有问题,动心把之前安装的node和npm手动都删掉了,高高兴兴地去用homebrew安装,结果发现高兴早了还有好多文件没删干净,这些在安装后报错并给提示,我就顺着它的提示一步步解决错误的地方,最后终于安装成功了,具体怎么解决这些错误就在这里记录一下。
一开始的错误是这样的:
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
Target /usr/local/share/doc/node/gdbinit
already exists. You may want to remove it:
rm '/usr/local/share/doc/node/gdbinit'To force the link and overwrite all conflicting files:
brew link --overwrite nodeTo list all files that would be deleted:
brew link --overwrite --dry-run nodePossible conflicting files are:
/usr/local/share/doc/node/gdbinit
/usr/local/share/doc/node/lldb_commands.py
/usr/local/share/man/man1/node.1
/usr/local/share/systemtap/tapset/node.stp
/usr/local/lib/dtrace/node.d
这里其实就是说,需要把这五个文件全部删掉,但是不能直接输入rm + file,这里给出了这样的回复override rw-r--r-- root/wheel for /usr/local/share/doc/node/gdbinit? 我太菜了也不知道要怎么答,所以在网上一查,原因应该是we should take back the ownership of files and directories under /usr/local
, 使用如下命令就可以了:
sudo chown -R `whoami`:admin /usr/local/share/doc/node/gdbinit /usr/local/share/doc/node/lldb_commands.py /usr/local/share/man/man1/node.1 /usr/local/share/systemtap/tapset/node.stp /usr/local/lib/dtrace/node.d
之后再输入brew link node,就会出现
Linking /usr/local/Cellar/node/17.7.1... 7 symlinks created.
就意味着node & npm已经顺利安装啦(撒花)。