错误:“ brew link”步骤未成功完成

macos的 Node.js

伽罗

2020-03-24

我正在尝试通过Homebrew安装node.js。不幸的是,我得到这个错误:

➜  ~  brew install node
==> Downloading http://nodejs.org/dist/v0.8.10/node-v0.8.10.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.8.10
==> make install
==> Caveats
Homebrew installed npm.
We recommend prepending the following path to your PATH environment
variable to have npm-installed binaries picked up:
  /usr/local/share/npm/bin
Warning: Could not link node. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link node'
==> Summary
/usr/local/Cellar/node/0.8.10: 856 files, 13M, built in 103 seconds

所以我尝试手动链接节点...

➜  ~  brew link node
Linking /usr/local/Cellar/node/0.8.10... Warning: Could not link node. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/node/0.8.10/lib/node_modules/npm/scripts/relocate.sh
Target /usr/local/lib/node_modules/npm/scripts/relocate.sh already exists. You may need to delete it.
To force the link and delete this file, do:
  brew link -f formula_name

To list all files that would be deleted:
  brew link -n formula_name

不走运,所以我尝试强制链接节点...

➜  ~  brew link -f node
Linking /usr/local/Cellar/node/0.8.10... Warning: Could not link node. Unlinking...

Error: Permission denied - /usr/local/lib/dtrace/node.d

我在任何方面都不熟悉dtrace,而且害怕弄乱权限,所以我尝试sudo。

➜ ~ git:(master) sudo brew link -f node
Password:
Error: Cowardly refusing to `sudo brew link'
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

我已经尝试通过卸载节点brew uninstall node并重试安装,但是没有运气。

第3617篇《错误:“ brew link”步骤未成功完成》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

20个回答
GO 2020.03.24

您需要手动删除npm软件包。

第一个取消链接节点: brew link -n node

删除npm文件夹: rm -R /usr/local/Cellar/node/0.8.10/lib/node_modules/npm

再次链接: brew link node

将会有一个指向npm新位置的软链接

米亚伽罗村村 2020.03.24

我通过使用以下命令在El Capitan中修复了此问题。老实说,不知道它做什么,但是我想分享一下,因为它解决了我的问题。

brew link --overwrite node
猴子村村 2020.03.24

我为此苦了一段时间。(对我而言,“ npm卸载npm -g”什么都不做)

我尝试了很多事情:

npm uninstall npm -g
brew uninstall node
brew install node

尝试链接节点文件时,我仍然遇到一些问题并出现错误

最后我尝试了这个

brew link --overwrite node

那似乎已经解决了。(它会覆盖所有冲突文件,并且还会链接节点和npm)

希望这可以帮助

AEva 2020.03.24

不知道这是否是一个好主意:尝试所有其他解决方案均未成功后,我只是重命名了/ usr / local / lib / dtrace,链接的节点并再次重命名了目录。之后,节点按预期工作。

西里神奇 2020.03.24

通过Finder,删除此文件:

/usr/local/lib/dtrace/node.d

在终端:

$ brew link --overwrite --dry-run node

然后:

$ brew link node
蛋蛋猿 2020.03.24

我完全卸载了brew,然后再次开始,只再次发现了相同的问题。

Brew通过将所需的二进制文件符号链接到您的系统中来工作,其他安装方法通常会复制这些文件。

我在这里找到了一组现有的节点库:

/usr/local/include/node

经过一番抓挠之后,我记得当时已针对该旧版本安装了节点,并且它不是通过brew来完成的。

我手动删除了整个文件夹,并成功链接了npm。

这可以解释为什么使用brew brew卸载甚至卸载brew本身都不起作用。

排名最高的答案非常简单,但是我想补充一下为什么有必要的看法。

我猜想其他Brew软件包的许多问题可能是由于软件包的旧的非酿造实例造成的。

小卤蛋 2020.03.24

我已经尝试了所有方法,但没有一个起作用。最简单的方法是从https://nodejs.org/en/download/重新安装节点

只需下载pkg并安装。现在我有一个工作npmnode试。

宝儿樱 2020.03.24

我还设法弄乱了这些Homebrew版本之间的NPM和安装的软件包,无论我取消链接/链接和卸载/安装的节点有多少次仍然无法正常工作。

事实证明,您必须从路径中删除NPM,否则Homebrew将不会安装它:https : //github.com/mxcl/homebrew/blob/master/Library/Formula/node.rb#L117

希望这可以帮助遇到相同问题的人并节省一个小时左右的时间,我不得不花时间寻找问题...

泡芙 2020.03.24

最终答案:将目录的所有者更改为您自己的所有者

sudo chown -R `whoami` /usr/local/include

如果您运行Brew Doctor,Brew也建议这样做

老丝阿飞 2020.03.24

大多数节点的brew安装问题是由于权限错误或先前已安装节点,然后尝试通过brew安装它引起的。最终对我有用的解决方案是:

警告:这将谨慎卸载使用的nodejs(多个版本):

  1. 通过brew删除节点:

    brew卸载节点

  2. 也通过武力做到了:

    brew卸载节点--force

  3. 要使用脚本Source:Remove node

    curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh

然后:

chmod +x /path/to/terminatenode.sh

然后:

./terminatenode.sh .
  1. 然后确保执行以下命令:

    chown $ USER / usr / local

  2. 然后进行一次brew更新(继续执行直到所有内容都更新为止):

    酿造更新

  3. 清理冲泡并再次运行更新(可能是多余的),并运行医生以确保一切就绪:

    冲泡清理;酿造更新;酿造医生

  4. 最后通过brew(详细)安装节点:

    brew install -v节点

宝儿理查德 2020.03.24

thx @suweller。

我解决了这个问题:

➜  bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...

Error: Permission denied - /usr/local/lib/node_modules/npm

我和suweller有同样的问题:

➜  bin git:(master) ✗ ls -la /usr/local/lib/ | grep node
drwxr-xr-x   3 24561  wheel   102 11 Okt  2012 node
drwxr-xr-x   3 24561  wheel   102 27 Jan 11:32 node_modules

所以我通过以下方式解决了这个问题:

➜  bin git:(master) ✗ sudo chown $(users) /usr/local/lib/node_modules
➜  bin git:(master) ✗ sudo chown $(users) /usr/local/lib/node

解决此问题后,我得到了另一个问题:

➜  bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
Target /usr/local/lib/dtrace/node.d already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

所以我通过以下方式删除了node.d:

➜  bin git:(master) ✗ sudo rm /usr/local/lib/dtrace/node.d

另一个权限错误:

➜  bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... Warning: Could not link node. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
/usr/local/lib/dtrace is not writable. You should change its permissions.

并修复它:

➜  bin git:(master) ✗ sudo chown $(users) /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d

最后一切正常:

➜  bin git:(master) ✗ brew link node
Linking /usr/local/Cellar/node/0.10.25... 1225 symlinks created
DavaidTony宝儿 2020.03.24

我在安装时遇到错误,无法链接节点,并且/ usr / local / include是不可写的

下面的解决方案为我工作:- 首先创建include文件夹,请注意,这需要sudo权限

cd /usr/local

sudo mkdir include

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

brew link node
Gil 2020.03.24

将所有应用程序从旧Mac转移到新Mac后,我遇到了同样的问题。

我通过运行找到解决方案brew doctor

警告:发现损坏的符号链接。用删除它们brew prune

运行后brew prune,Homebrew终于回到正轨:)

Tom凯 2020.03.24

我的问题有一个稍微不同的解决方案。brew要在其中创建符号链接的目录不属于当前用户。

ls -la /usr/local/bin/lib/node | grep node 产生:

drwxr-xr-x    3 24561  wheel   102 May  4  2012 node
drwxr-xr-x    7 24561  wheel   238 Sep 18 16:37 node_modules

对我来说,以下内容可以解决此问题:

sudo chown $(users) /usr/local/bin/lib/node_modules
sudo chown $(users) /usr/local/bin/lib/node

ps。$(users)将扩展到您的用户名,竭尽全力帮助懒惰的复制粘贴者;)

乐小哥 2020.03.24

现在,用于node.js的自制程序包再次包含npm,所以当我错过了自制程序包中有关先删除独立版本的消息时,这件事发生在我身上。

假设,像我一样,你已经通过尝试升级知道要打破之前节点/ NPM npm uninstall npm -g首先,你可以rm -rf /usr/local/lib/node_modules/npmbrew link node这将删除独立的自托管npm软件包(而不是要安装的一个brew),并让brew从Cellar对其捆绑的软件包进行符号链接。

凯村村 2020.03.24

您可能已经使用其他方法安装了旧版本的node.js,因此您需要手动删除以brew方式获取的文件。

请执行brew link -n node并手动删除那些冲突的文件和目录,然后重试brew link node

泡芙伽罗小卤蛋 2020.03.24
sudo chown -R $(whoami) /usr/local 

就像酿造现场故障排除中提到的那样很好

https://github.com/Homebrew/homebrew/wiki/troubleshooting

神乐 2020.03.24

我来晚了,对我有用的是:

* npm uninstall npm -g

* brew uninstall node

* brew install node

* sudo rm -rf /usr/local/lib/dtrace/node.d

* brew link node (caused error with permissions)

* sudo chmod 777 /usr/local/lib/dtrace/node.d

* brew link node

在此顺序之后一切都成功了

Tony凯 2020.03.24

尝试这个。从另一个参考那里得到了帮助。

brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) /usr/local
brew link --overwrite node
brew postinstall node
猪猪 2020.03.24

我运行Mac OS X Mavericks。我尝试安装节点0.10.25,但最佳答案对我不起作用。

natevw说,rm -rf /usr/local/lib/node_modules/npm但是如果权限/usr/local/lib/node_modules如下所示:

drwxr-xr-x   3 root      admin   102 Feb  2 20:45 node_modules

然后brew将无法在该目录中创建其npm符号链接。这是我的解决方案:

步骤1:更新自制程序

$ brew update

Step 2: Remove node/npm everywhere on your system

Some of these commands are not necessary depending on how you installed node/npm in the past.

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

Note: I had stray node files that I found by running brew -v link node (which gave me the verbose output of the linking errors brew was complaining about). You may need to:

$ sudo rm -rf /usr/local/include/node
$ sudo rm -rf /usr/local/lib/node

Step 3: Open a new terminal and install node

$ brew install node

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android