node.js Homebrew npm install:无法符号链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32849741/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 19:20:19  来源:igfitidea点击:

Homebrew npm install: could not symlink

node.jsnpmhomebrew

提问by pwhitt

So I made the mistake of trying to get rid of all sudo dependencies. I downloaded npm as a package from the site and did a manual/global install. But it seemed as if i was always having to run with sudo...so I tried to uninstall and run with homebrew.

所以我犯了一个错误,试图摆脱所有 sudo 依赖。我从站点下载了 npm 作为一个包,并进行了手动/全局安装。但似乎我总是不得不使用 sudo 运行……所以我尝试卸载并使用自制软件运行。

Now I can't get node or npm to even run...I guess I have to link with brew link them but i'm getting this error:

现在我什至无法让 node 或 npm 运行...我想我必须与 brew link 它们链接,但我收到此错误:

Could not symlink share/doc/node/gdbinit
Target /usr/local/share/doc/node/gdbinit
already exists. You may want to remove it:
  rm '/usr/local/share/doc/node/gdbinit'

I've tried removing that: And i've gotten permission denied.

我试过删除它:而且我的许可被拒绝。

I have tried running brew prune. I have tried to uninstall then reinstall using these steps:

我试过运行 brew prune。我尝试使用以下步骤卸载然后重新安装:

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

Error: The 'brew link' step did not complete successfully

错误:“酿造链接”步骤未成功完成

I am running Yosemite 10.10.5. I have git version 2.6.0 installed. My homebrew is updated. A brew doctor gives me this warning:

我正在运行优胜美地 10.10.5。我安装了 git 版本 2.6.0。我的自制软件已更新。一位酿造医生给了我这个警告:

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

Not sure where to go from here. I'm trying to lose my reliance on CodeKit and get gulp up and running.

不知道从这里去哪里。我正在尝试摆脱对 CodeKit 的依赖,并开始运行。

回答by nwinkler

It looks like several files and directories in /usr/localare now owned by root, since you ran a couple of steps using sudo. To get rid of these, take back ownership of all of the files and directories under /usr/local:

它看起来像几个文件和目录/usr/local现在所拥有root的,因为你跑了几个使用步骤sudo。要摆脱这些,请收回以下所有文件和目录的所有权/usr/local

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

Once that is done, run brew doctoragain.

完成后,brew doctor再次运行。

Similar questions can be found here:

类似的问题可以在这里找到:

回答by Rohit Mandiwal

In my case, I was continue to execute command brew link nodeand upon every execution, it is keep on saying to remove some files. I just followed the instructions and keep on removing them with sudo. At last, after 5 such removals, I have the linking done.

就我而言,我一直在执行命令brew link node,每次执行时,一直说要删除一些文件。我只是按照说明操作并继续使用sudo. 最后,经过 5 次这样的删除,我完成了链接。

enter image description here

在此处输入图片说明