node.js 错误:“酿造链接”步骤未成功完成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12607155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: The 'brew link' step did not complete successfully
提问by chandlervdw
I'm trying to install node.js via Homebrew. Unfortunately, I get this error:
我正在尝试通过 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
So then I try to link node manually...
那么我尝试手动链接节点......
? ~ 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
No luck, so I try forcefully linking node...
不走运,所以我尝试强行链接节点...
? ~ 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
I'm not familiar with dtrace in any regard and I'm afraid to mess with permissions, so I tried to sudo..
我在任何方面都不熟悉 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.
I've tried uninstalling node via brew uninstall nodeand retrying the install with no luck.
我尝试通过卸载节点brew uninstall node并重试安装但没有运气。
采纳答案by natevw
The homebrew package for node.js now includes npm again, so this happened to me when I missed the homebrew package's message about removing the standalone version first.
node.js 的 homebrew 包现在再次包含 npm,所以当我错过 homebrew 包关于首先删除独立版本的消息时,这发生在我身上。
Assuming, like me, you've already broken node/npm by attempting the upgrade before knowing to npm uninstall npm -gfirst, you can rm -rf /usr/local/lib/node_modules/npmand then brew link node. This removes the standaloneself-hosted npm package (rather than the one brew would like to install) and lets brew symlink its bundled one from Cellar.
假设,像我一样,你已经通过在知道之前尝试升级而破坏了 node/npm npm uninstall npm -g,你可以rm -rf /usr/local/lib/node_modules/npm,然后brew link node. 这删除了独立的自托管 npm 包(而不是 brew 想要安装的),并让 brew 符号链接其从 Cellar 捆绑的包。
回答by franksort
I run Mac OS X Mavericks. I tried to install node 0.10.25 and the top answer did not work for me.
我运行 Mac OS X Mavericks。我尝试安装节点 0.10.25,但最佳答案对我不起作用。
natevw says to rm -rf /usr/local/lib/node_modules/npmbut if the permissions on /usr/local/lib/node_moduleslook like this:
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
then brew will not be able to create its npm symlink in that directory. Here's my solution:
那么 brew 将无法在该目录中创建它的 npm 符号链接。这是我的解决方案:
Step 1: Update Homebrew
第 1 步:更新 Homebrew
$ brew update
Step 2: Remove node/npm everywhere on your system
第 2 步:删除系统上任何地方的 node/npm
Some of these commands are not necessary depending on how you installed node/npm in the past.
根据您过去安装 node/npm 的方式,其中一些命令不是必需的。
$ 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:
注意:我有通过运行找到的杂散节点文件brew -v link node(它给了我 brew 抱怨的链接错误的详细输出)。您可能需要:
$ sudo rm -rf /usr/local/include/node
$ sudo rm -rf /usr/local/lib/node
Step 3: Open a new terminal and install node
第 3 步:打开一个新终端并安装节点
$ brew install node
回答by Talal
sudo chown -R $(whoami) /usr/local
would do just fine as mentioned in the brew site troubleshooting
就像 brew site 故障排除中提到的那样就好了
回答by Trevor Dixon
You probably already installed an older version of node.js using a different method, so you need to manually remove the files that are getting in brew's way.
您可能已经使用不同的方法安装了旧版本的 node.js,因此您需要手动删除妨碍 brew 的文件。
Do brew link -n nodeand manually delete those conflicting files and directories, then try brew link nodeagain.
执行brew link -n node并手动删除那些冲突的文件和目录,然后重试brew link node。
回答by Will
I'm a bit late, what worked for me was this:
我有点晚了,对我有用的是:
* 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
Everything was successful after this sequence
在这个序列之后一切都成功了
回答by Randula
Try this. Got from another reference and worked for me.
尝试这个。从另一个参考资料中得到并对我来说有效。
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
回答by Kévin L. R.
I had the same problem after transferring all my applications from my old Mac to my new one.
将所有应用程序从旧 Mac 转移到新 Mac 后,我遇到了同样的问题。
I found the solution by running brew doctor:
我通过运行找到了解决方案brew doctor:
Warning: Broken symlinks were found. Remove them with
brew prune
警告:发现损坏的符号链接。删除它们
brew prune
After running brew prune, Homebrew is finally back on track :)
运行后brew prune,Homebrew 终于回到正轨:)
回答by suweller
My problem had a slightly different solution. The directory in which brew wanted to create the symlinks were not owned by the current user.
我的问题有一个稍微不同的解决方案。brew 想要在其中创建符号链接的目录不属于当前用户所有。
ls -la /usr/local/bin/lib/node | grep nodeyielded:
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
For me, the following fixed it:
对我来说,以下修复了它:
sudo chown $(users) /usr/local/bin/lib/node_modules
sudo chown $(users) /usr/local/bin/lib/node
ps. $(users)will get expanded to your username, went a little out of my way to help out lazy copy pasters ;)
附:$(users)将扩展到您的用户名,我有点想帮助懒惰的复制粘贴者;)
回答by zero3nna
thx @suweller.
谢谢@suweller。
I fixed the problem:
我解决了这个问题:
? 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
I had the same problem as suweller:
我和 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
so i fixed this problem by:
所以我通过以下方式解决了这个问题:
? bin git:(master) ? sudo chown $(users) /usr/local/lib/node_modules
? bin git:(master) ? sudo chown $(users) /usr/local/lib/node
after i fixed this problem I got another one:
在我解决了这个问题后,我又得到了一个:
? 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
So I removed node.d by:
所以我通过以下方式删除了 node.d:
? bin git:(master) ? sudo rm /usr/local/lib/dtrace/node.d
got another permission error:
有另一个权限错误:
? 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.
and fixed it:
并修复它:
? bin git:(master) ? sudo chown $(users) /usr/local/Cellar/node/0.10.25/lib/dtrace/node.d
and finally everything worked:
最后一切正常:
? bin git:(master) ? brew link node
Linking /usr/local/Cellar/node/0.10.25... 1225 symlinks created
回答by AhsenB
Most brew install issues with node are caused by permission errors or having node previously installed and then trying to install it via brew. The solution that worked for me finally was:
node 的大多数 brew install 问题是由权限错误或先前安装 node 然后尝试通过 brew 安装它引起的。最终对我有用的解决方案是:
WARNING: This will uninstall nodejs (multiple versions) use with caution:
警告:这将卸载 nodejs(多个版本)谨慎使用:
Remove node via brew:
brew uninstall node
also did via force:
brew uninstall node --force
To use the script Source: Remove node:
curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh
通过 brew 删除节点:
brew卸载节点
也通过武力做到了:
brew 卸载节点 --force
使用脚本源:删除节点:
curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh
Then:
然后:
chmod +x /path/to/terminatenode.sh
Then:
然后:
./terminatenode.sh .
Then make sure to do the following command:
chown $USER /usr/local
Then do a brew update (keep doing this until all things are updated):
brew update
Clean brew up and run update again (might be redundant) and run doctor to make sure things are in place:
brew cleanup; brew update; brew doctor
And finally install node via brew (verbose):
brew install -v node
然后确保执行以下命令:
chown $USER /usr/local
然后做一个 brew update (继续这样做直到所有东西都更新了):
酿造更新
清理 brew 并再次运行更新(可能是多余的)并运行医生以确保一切就绪:
酿造清理;酿造更新;酿造医生
最后通过 brew (verbose) 安装节点:
brew install -v 节点

