家酿 npm 安装: 无法符号链接

所以我犯了一个错误,试图去除所有的 sudo 依赖项。我从站点下载了 npm 作为一个软件包,并进行了手动/全局安装。但似乎我总是要运行 sudo... ... 所以我试图卸载和运行自制程序。

现在,我甚至不能让 node 或 npm 运行... 我想我必须链接与酿造链接他们,但我得到这个错误:

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'

我试过移除它: 我被拒绝了。

我试过酿李子。 我尝试用以下步骤卸载然后重新安装:

$ brew uninstall npm
$ brew uninstall node
$ npm uninstall npm -g
$ sudo rm -rf /usr/local/lib/node_module

错误: 酿造链接没有成功完成步骤

我正在运行优胜美地10.10.5。我已经安装了 git 2.6.0版。我的自制程序升级了。一个酿酒医生给了我这样一个警告:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
node

不知道接下来该怎么办。我正在努力摆脱对 CodeKit 的依赖,开始大口吞咽并运行。

66611 次浏览

It looks like several files and directories in /usr/local are now owned by root, since you ran a couple of steps using sudo. To get rid of these, take back ownership of all of the files and directories under /usr/local:

sudo chown -R $(whoami) $(brew --prefix)/*

Once that is done, run brew doctor again.

Similar questions can be found here:

In my case, I was continue to execute command brew link node and upon every execution, it is keep on saying to remove some files. I just followed the instructions and keep on removing them with sudo. At last, after 5 such removals, I have the linking done.

enter image description here

Had something similar happen with node listed as an unlinked keg. This is what worked for me on MacOS Big Sur:

  1. sudo mkdir -p /usr/local/sbin // had issues with sbin, ignore if you don't.
  2. sudo chown -R $(whoami) /usr/local/sbin // ignore if sbin isn't an issue.
  3. brew link --overwrite node
  4. brew cleanup // wanted to be sure this alone ran fine :)
  5. brew doctor // found un brewed header files, but not concerned about those.
  6. node -v // checking node version
  7. npm -v // checking npm version

If the above doesn't work, try starting from scratch and seeing if these steps help:

  1. brew uninstall node
  2. brew update
  3. brew upgrade
  4. brew cleanup
  5. brew install node
  6. sudo chown -R $(whoami) /usr/local
  7. brew link --overwrite node
  8. brew postinstall node

You can definitely chain these commands and make the input way shorter, but small victories help ease some of the frustration, while also making it easier to ID exactly what step failed, rather than displaying a chained-command error and having the person rage (╯°□°)╯︵ ┻━┻ because they are now even more lost lol.