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

匿名 (未验证) 提交于 2019-12-03 02:34:02

问题:

I'm trying to install node.js via Homebrew. Unfortunately, I get this error:

So then I try to link node manually...

No luck, so I try forcefully linking node...

I'm not familiar with dtrace in any regard and I'm afraid to mess with permissions, so I tried to sudo..

I've tried uninstalling node via brew uninstall node and retrying the install with no luck.

回答1:

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.

Assuming, like me, you've already broken node/npm by attempting the upgrade before knowing to npm uninstall npm -g first, you can rm -rf /usr/local/lib/node_modules/npm and then brew link node. This removes the standalone self-hosted npm package (rather than the one brew would like to install) and lets brew symlink its bundled one from Cellar.



回答2:

I run Mac OS X Mavericks. I tried to install node 0.10.25 and the top answer did not work for me.

natevw says to rm -rf /usr/local/lib/node_modules/npm but if the permissions on /usr/local/lib/node_modules look like this:

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:

Step 1: Update Homebrew

$ brew update 

Step 2: Remove node/npm everywhere on your system

Some of these commands are not necessary depending on how you installed node/npm in the past.

$ 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:

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

Step 3: Open a new terminal and install node

$ brew install node 


回答3:

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.

Do brew link -n node and manually delete those conflicting files and directories, then try brew link node again.



回答4:

sudo chown -R $(whoami) /usr/local  

would do just fine as mentioned in the brew site troubleshooting

https://github.com/Homebrew/homebrew/wiki/troubleshooting



回答5:

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



回答6:

Try this. Got from another reference and worked for me.

sudo brew uninstall node brew update brew upgrade brew cleanup brew install node sudo chown -R $(whoami) /usr/local brew link --overwrite node sudo brew postinstall node 


回答7:

I had the same problem after transferring all my applications from my old Mac to my new one.

I found the solution by running brew doctor :

Warning: Broken symlinks were found. Remove them with brew prune

After running brew prune, Homebrew is finally back on track :)



回答8:

My problem had a slightly different solution. The directory in which brew wanted to create the symlinks were not owned by the current user.

ls -la /usr/local/bin/lib/node | grep node yielded:

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 ;)



回答9:

thx @suweller.

I fixed the problem:

I had the same problem as suweller:

so i fixed this problem by:

after i fixed this problem I got another one:

So I removed node.d by:

got another permission error:

and fixed it:

and finally everything worked:



回答10:

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:

WARNING: This will uninstall nodejs (multiple versions) use with caution:

  1. Remove node via brew:

    brew uninstall node

  2. also did via force:

    brew uninstall node --force

  3. To use the script Source: Remove node:

    curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh

Then:

chmod +x /path/to/terminatenode.sh 

Then:

./terminatenode.sh . 
  1. Then make sure to do the following command:

    chown $USER /usr/local

  2. Then do a brew update (keep doing this until all things are updated):

    brew update

  3. 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

  4. And finally install node via brew (verbose):

    brew install -v node



回答11:

the ultimate answer: change the owner of that directory to whoever you are

sudo chown -R `whoami` /usr/local/include 

which is also recommended by brew if you run brew doctor



回答12:

I also managed to mess up my NPM and installed packages between these Homebrew versions and no matter how many time I unlinked / linked and uninstalled / installed node it still didn't work.

As it turns out you have to remove NPM from the path otherwise Homebrew won't install it: https://github.com/mxcl/homebrew/blob/master/Library/Formula/node.rb#L117

Hope this will help someone with the same problem and save that hour or so I had to spend looking for the problem...



回答13:

Don't know, if it's a good idea or not: After trying all other solutions without success, I just renamed /usr/local/lib/dtrace, linked node and re-renamed the directory again. After that, node worked as expected.



回答14:

I was struggling with this for a while. (for me "npm uninstall npm -g" did nothing)

I tried a bunch of things:

npm uninstall npm -g brew uninstall node brew install node 

I was still having some issues and was getting errors when i tried to link the node files

Finally i tried this

brew link --overwrite node 

That seemed to have fixed it. (it overwrites al the conflicting files and also links node and npm)

Hope this helps



回答15:

I completely uninstalled brew and started again, only to find the same problem again.

Brew appears to work by symlinking the required binaries into your system where other installation methods would typically copy the files.

I found an existing set of node libraries here:

/usr/local/include/node

After some head scratching I remembered installing node at the date against this old version and it hadn't been via brew.

I manually deleted this entire folder and successfully linked npm.

This would explain why using brew uninstall or even uninstall brew itself had no effect.

The highest ranked answer puts this very simply, but I thought I'd add my observations about why it's necessary.

I'm guessing a bunch of issues with other brew packages might be caused by old non-brew instances of packages being in the way.



回答16:

Had been wrecking my head on symlinking node .. and nothing seemed to work...but finally what worked is setting the right permissions . This 'sudo chown -R $(whoami) /usr/local' did the work for me.



回答17:

I fixed this in El Capitan by using the following command. Honestly, no idea what it does, but thought I'd share since it fixed my problem.

brew link --overwrite node 


回答18:

by the Finder, Delete this file:

/usr/local/lib/dtrace/node.d

in terminal:

$ brew link --overwrite --dry-run node 

then:

$ brew link node 


回答19:

You need to remove the npm package manually.

first unlink node: brew link -n node

remove npm folder: rm -R /usr/local/Cellar/node/0.8.10/lib/node_modules/npm

link again: brew link node

there will be a soft link to the new location of npm



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!