Node.js 未链接错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12663488/
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
Node.js not linked error
提问by Ali
I've literally searched everything on web. But I could not find the solution for the error node-0.8.8 already installed, it's just not linked. Is it related to a path file issue?
我真的在网上搜索了所有内容。但是我找不到错误的解决方案node-0.8.8 already installed, it's just not linked。它与路径文件问题有关吗?
回答by 6754534367
Execute this list of commands in this particular order:
按此特定顺序执行此命令列表:
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) $(brew --prefix)
brew link --overwrite node
brew postinstall node
回答by arete
After you've run brew upgradeto update node to the latest version, run brew doctorto see what potential problems there are. It might tell you that node is unlinked, in which case, running brew link nodewill link it. (You might need to first run brew unlink node)
在运行brew upgrade将 node 更新到最新版本后,运行brew doctor以查看存在哪些潜在问题。它可能会告诉您节点未brew link node链接,在这种情况下,运行将链接它。(您可能需要先运行brew unlink node)
回答by NSNoob
I got the same error today and it told me that Node was not properly linked and there were unexpected header files as well.
我今天遇到了同样的错误,它告诉我 Node 没有正确链接,并且还有意外的头文件。
When I tried to reinstall node, It told me that it was already installed, just not linked.
当我尝试重新安装节点时,它告诉我它已经安装,只是没有链接。
Warning: /usr/local/include isn't writable
/usr/local/bin/node already exists. Remove it
Solution
解决方案
To fix this, I took ownership of it by using:
为了解决这个问题,我使用以下方法获得了它的所有权:
sudo chown -R `whoami` /usr/local/
Then I force linked all files by using:
然后我通过使用强制链接所有文件:
brew link --overwrite node
After that I did the post install routine with:
之后,我执行了安装后例程:
brew postinstall node
Then I checked if node was properly installed with:
然后我检查节点是否正确安装:
node -v
I received output v5.1.0and It was fixed :). Hope this helps.
我收到了输出v5.1.0并已修复:)。希望这可以帮助。
This may not be the perfect fix out there since I have started dabbling with node and homebrew just 10 minutes ago but it did the job for me.
这可能不是完美的解决方案,因为我在 10 分钟前开始涉足 node 和自制软件,但它为我完成了这项工作。
回答by NSNoob
Your old version of Node 0.5 was probably not installed with Homebrew (or Homebrew's script changed in the large gap between the 0.5 beta releases to the 0.8 stable releases (the 0.6 and 0.7 releases in-between).
您的旧版本 Node 0.5 可能没有安装 Homebrew(或者 Homebrew 的脚本在 0.5 beta 版本和 0.8 稳定版本(中间的 0.6 和 0.7 版本)之间的巨大差距中发生了变化。
Both Homebrew and the official Node installer try to install to /usr/local/binso I'd recommend starting by simply deleting /usr/local/bin/node, /usr/local/bin/npm, and /usr/local/lib/nodeand try again.
无论家酿和官方节点安装程序尝试安装到/usr/local/bin那么我建议你通过简单的删除开始/usr/local/bin/node,/usr/local/bin/npm和/usr/local/lib/node,然后再试一次。
回答by Kuriakin Zeng
hardcorepunk's answer worked. However, we can no longer chown /usr/localin High Sierra. So, execute the commands in this order:
铁杆朋克的回答奏效了。但是,我们不能再/usr/local在 High Sierra 中吃东西了。因此,按以下顺序执行命令:
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) $(brew --prefix)/*
brew link --overwrite node
brew postinstall node
回答by Rohini Choudhary
To link the node, run following command:
要链接节点,请运行以下命令:
brew link homebrew/versions/node<version no>
And to check whether it is properly installed or not, run:
并检查它是否正确安装,运行:
node -v
If node will get properly linked, it will not through any error, and will print node version. You can read nice explanation about it from here.
如果节点正确链接,则不会出现任何错误,并会打印节点版本。你可以从这里阅读关于它的很好的解释。
回答by MCMatan
For line did the job:
对于线完成了这项工作:
brew link --overwrite node
It forces the link and overwrite all conflicting files:
它强制链接并覆盖所有冲突文件:
回答by Mavlarn
You can change the permission of the file "/usr/local/bin/node", like "chmod +w /usr/local/bin/node", to make it writable.
您可以更改文件的权限"/usr/local/bin/node",例如"chmod +w /usr/local/bin/node",使其可写。

