macos - 错误 : The 'brew link' step did not complete successfully

标签 macos node.js npm homebrew

我正在尝试通过 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

然后我尝试手动链接 Node ...

➜  ~  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

没有运气,所以我尝试强制链接 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

我在任何方面都不熟悉 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 卸载 Node 并重试安装,但没有成功。

最佳答案

我运行 Mac OS X Mavericks。我尝试安装 Node 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 符号链接(symbolic link)。这是我的解决方案:

第 1 步:更新 Homebrew

$ brew update

第 2 步:删除系统上所有位置的 node/npm

根据您过去安装 node/npm 的方式,其中一些命令不是必需的。

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

注意:我通过运行 brew -v link node 找到了杂散的 Node 文件(这给了我 brew 提示的链接错误的详细输出)。您可能需要:

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

第三步:打开一个新的终端并安装 Node

$ brew install node

关于macos - 错误 : The 'brew link' step did not complete successfully,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12607155/

相关文章:

node.js - windows 10 socket.io安装错误

macos - 我的 Mac 应用程序是否需要应用文件访问授权 key 才能支持拖放?

macos - 以编程方式在启动时启动 Mac 应用程序

Node.JS Express 4 - Mongoose 不保存数据

javascript - Node.js:有哪些技术可以编写干净、简单的回调代码?

javascript - Angular 5.2 : Getting error while building application using VSTS build server : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

node.js - Aurelia 构建失败 - 找不到模块 babel-runtime

mysql - 在 OSX Mavericks 上安装 mysql 时遇到问题

macos - Xcode 构建错误 'InputFile' 应该恰好有五个参数

node.js - 在mongodb中查询字符串日期格式