Try sudo chown -R $(whoami) /usr/local/
then rerun brew link --overwrite node
edit
This is the same problem I had the last two times I had to brew link node and it solved my problem.
^^^^^^^^^^^^^^^^^^^^^^^
This is what not to do. Although it does work for the question given, it is reckless. Don't believe everything you read on the internet like I used to. ;) Below are a number of ways to uninstall node.js from OSX in general followed by a better way to solve the problem presented in this question. All of this was found with google... and usually lead me back to StackOverflow. The basic idea being that everything needs to go.
NPM(Safest)
sudo npm uninstall npm -g
Removes all files.
sudo rm -rf /usr/local/lib/node \
/usr/local/include/node \
/usr/local/lib/node_modules \
/usr/local/include/node_modules \
/var/db/receipts/org.nodejs.*
Removes extraneous bash pathnames.
If You Installed From The Node.js Website
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
A Script You Can Try(w/ homebrew)
This one is updated more frequently then the next one listed below and is very methodical. It does attempt to use some brew commands so dont use it if you don't use homebrew. It does have a list of all problem directories, which is nice. Source. More info. Ignore the suggestion for the chown
command at the end as removal of node should be done without changing permissions of critical system directories.
curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh
chmod +x /path/to/terminatenode.sh
./terminatenode.sh
Another Script You Can Try
This gist was created by NiceRobot. Gist is here. Please read it before you run it to make sure you're comfortable running this script. It does require sudo as all of these options do.
curl -ksO https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh
Downloads the script.
chmod u+x ./uninstall-node.sh
Enables execution of the script by you.
./uninstall-node.sh
Runs the script
which node
Checks to see if node is still installed. If so, choose another option.
rm uninstall-node.sh
Deletes the script.
The specific problem presented by this question can be dealt with with the following. Thanks for everyone's comments/recommendations. Hope all this helps someone now that all this can be found in one answer.
sudo rm -rf /usr/local/include/node
sudo rm -rf /usr/local/include/node_modules
References
- NiceRobot
- Another Q&A on StackOverflow
- This website.