I'm in the process of uninstalling and reinstalling node and npm on my MacBook.
So far I've done:
- sudo rm -rf /usr/local/lib/node_modules/npm/
- brew uninstall node
- brew unlink node
- sudo rm -rf [any and all node-related files and directories]
- brew doctor
- brew prune
- brew install node
- brew link node
Every step works fine up until the link. When I try brew link --overwite node, I get this error:
Linking /usr/local/Cellar/node/0.10.33...
Error: Could not symlink include/node/ares.h /usr/local/include/node is not writable.
Here's the related stack overflow: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
It may be a matter of tweaking the sequence. Has anyone gone through the process and have any tips? I noticed someone has already tried to install node on the production laptop I'm also using and run into the identical brew link error.
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.
This post is a little stale, but I've followed the recommendations here for how to uninstall Node.js with little success. Deleting the node and node_modules in /usr/local/lib and /usr/local/include didn't do it for me, and I don't have homebrew installed. In the end it really ends up being pretty simple.
Check your path variable - in terminal enter:
echo $PATH
Go to each directory in the list that is emitted, and start deleting out anything named node or node_modules. After each one check to see if you've uninstalled it; simply attempting to check the version of Node.js should suffice - in terminal enter:
node -v
While it is installed you'll see a version emitted. When you see some other message (perhaps "file or directory not found") you know you've uninstalled it manually.
At the time of this post I can download an installer on nodejs.org, which seems to install the latest version okay.
Try this and use nvm to reinstall it. NVM give you the option to install any node version that you need.