使用homebrew安装Node.js出现问题

4

我正在尝试使用Homebrew在OS X上安装Node.js,但遇到了一些问题,不太确定如何解决。当我运行brew doctor时,会得到以下输出:

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

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

Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
    cd /usr/local/Library && git stash && git clean -d -f
Error: Homebrew doesn't know what compiler versions ship with your version
of Xcode (5.1). Please `brew update` and if that doesn't help, file
an issue with the output of `brew --config`:
  https://github.com/Homebrew/homebrew/issues

Note that we only track stable, released versions of Xcode.

Thanks!

我尝试运行brew link node,并收到以下消息:

Linking /usr/local/Cellar/node/0.10.26... Warning: Could not link node. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/node/0.10.26/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

然后我尝试运行brew link --overwrite node,但是遇到了以下错误:

Linking /usr/local/Cellar/node/0.10.26... Warning: Could not link node. Unlinking...

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

我现在卡住了,不太确定该怎么做。非常感谢您的帮助。

3个回答

6

我通过运行以下命令解决了这个问题:

sudo chown -R `whoami` /usr/local

2
尝试解决权限问题,请执行以下操作:
sudo brew link --overwrite node

请注意,除非您有特定的原因使用homebrew安装node,否则我建议您只需转到http://nodejs.org/,下载Mac OS安装程序并让它为您完成一切。

2
这对我不起作用。它返回了这种类型的错误:“错误:懦弱地拒绝sudo brew link。您可以使用sudo运行brew,但前提是brew可执行文件归root所有。然而,这既不被推荐也完全不受支持,因此自行承担风险。” 我猜brew对我来说不是由root拥有的。 - David

0

我来晚了,但我遇到了同样的问题-不过我觉得我找到了解决方法。

运行ls -al /usr/local/lib/dtrace/node.d检查/usr/local/lib/dtrace/node.d的权限。如果所有者不是你的用户名,请通过运行以下命令进行修复:

sudo chown -R $USER:staff /usr/local/lib/dtrace/node.d

这应该给你所需的权限,让你继续进行。之后,我遇到了一些所有者列为 nobody 的目录(实际上我最终将 /usr/local/Cellar 下的所有内容都 chown 了,我会等待评论来看这是否是一个糟糕的想法)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接