71
votes

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.

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:

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

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.

2
I've tried removing that: And i've gotten permission denied. - That's because you installed as root in the first place. Now you have to remove using sudo rm '/usr/local/share/doc/node/gdbinit'. Note: If you use homebrew, do not install anything with sudo install anymore into /usr/local. This will create a huge mess.cel
Now I get 'could not symlink share/system/systemtap/tapset/node.stp /usr/local/share/system/tapset is not writable. I have tried doing a sudo chown -R 'username'/usr/local/share/system/tapset but that didn't work.pwhitt
I would simply delete all colliding files. It's a bit quirky, but that's why we have awesome package managers like hombrew. Manually uninstalling is simply way too painful.cel
As you can tell, I'm new using the command line for installation removal of files...do I have to go one by one trying to delete conflicting files? Homebrew does have a command that says it would overwrite the node files but it doesn't seem to do the trick.pwhitt

2 Answers

212
votes

It looks like several files and directories in /usr/local are 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:

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

Once that is done, run brew doctor again.

Similar questions can be found here:

20
votes

In my case, I was continue to execute command brew link node and 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.

enter image description here