To run this, you can try:
curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh
chmod +x ./uninstall-node.sh
./uninstall-node.sh
rm uninstall-node.sh
#!/bin/sh | |
(( ${#} > 0 )) || { | |
echo 'DISCLAIMER: USE THIS SCRIPT AT YOUR OWN RISK!' | |
echo 'THE AUTHOR TAKES NO RESPONSIBILITY FOR THE RESULTS OF THIS SCRIPT.' | |
echo "Disclaimer aside, this worked for the author, for what that's worth." | |
echo 'Press Control-C to quit now.' | |
read | |
echo 'Re-running the script with sudo.' | |
echo 'You may be prompted for a password.' | |
sudo ${0} sudo | |
exit $? | |
} | |
# This will need to be executed as an Admin (maybe just use sudo). | |
for bom in org.nodejs.node.pkg.bom org.nodejs.pkg.bom; do | |
receipt=/var/db/receipts/${bom} | |
[ -e ${receipt} ] && { | |
# Loop through all the files in the bom. | |
lsbom -f -l -s -pf ${receipt} \ | |
| while read i; do | |
# Remove each file listed in the bom. | |
rm -v /usr/local/${i#/usr/local/} | |
done | |
} | |
done | |
# Remove directories related to node.js. | |
rm -vrf /usr/local/lib/node \ | |
/usr/local/lib/node_modules \ | |
/var/db/receipts/org.nodejs.* | |
exit 0 |
Thanks. |
Great script, thanks! Just FYI to anyone out there new to running shell scripts: I had to run |
Had to use mhulse's method to get it to work, thanks though! |
Awesome. Worked great, thanks! |
I don't know if is really necessary, but i thing the script should delete ~/.node-gyp y ~/.npm from the local user, maybe even test is there are that directories in other users so you completely remove all what node.js creates |
What is the purpose of (( ${#} > 0 )) ? |
node 0.11.x forgot delete |
@roman, it's a hack to skip the first block on the next run. |
Thanks, nice stuff. |
Thanks! Doesn't work when piped directly from curl to the shell as there is no command line to test in the first block. Might work with "sudo bash" instead, but I didn't bother to hash it out. |
Thanks, worked great. And thanks for the tip mhulse. |
Excellent job. Thanks! |
https://gist.github.com/ddo/668630454ea0d74fdc21 update github url |
Worked a treat for me just by saving the script locally and chmod 755 the resulting file |
For now, it seems to be executed successfully! |
Dint work for me :( |
/usr/bin/sudo: /usr/bin/sudo: cannot execute binary file |
@TanayGahlot Sorry, if you were using the |
Weird, I am getting the message Update: |
@schystz It looks like node's |
What about org.nodejs.node.npm.pkg.plist org.nodejs.pkg.plist? |
Thank you - this worked perfectly! |
Nice job!! |
Nice Work!! Thank You!!! |
Thank you I just run under el capitan and everything seems fine |
Seems to freeze terminal for me after echo'ing Press Control-C to quit now. |
having the same problem as @ryan-lynch. after letting it run for a few minutes, I just killed the program. |
/usr/bin/sudo: /usr/bin/sudo: cannot execute binary file @nicerobot |
@vvardhanz use alternative solution. |
Thanks!! - Great Script!! |
Running the script by pasting it into a local .sh file worked. Running it through curl did not (at least the first option described here). However, I wanted to replace my package installed node by a brew install, but I got the following error:
Removing it made brew link up node properly. Maybe this should be added to the removals? (Uninstalled node v4.3.1 and installed v5.6.0 through brew) |
@ryan-lynch @youngrrrr The script will not start until you press return. |
Thanks!! |
Thank you I am using NodeJS package from the official website in El Capitan, then I run the script and everything seems fine. |
Works like charm!
|
How about virtualising Node.js within Docker in the first place? Right now, Docker appears to be targeted towards builds and production, but IMHO it's a perfect tool to distribute, customise and share developer environments as well. I took a first (quite humble - I'm a newbie to both Docker and Node.js) approach at https://blog.saddey.net/2016/07/03/using-docker-to-create-ionic-2-pwa-developer-environment/ Does this make any sense? |
@doncadavona's solution worked like a charm. |
@doncadavona's comment worked! Thanks for this gist! |
the screen is frozen, im trying to uninstall node js from my computer and reinstall it wt homebrew..any help will be appreciated. i have os x el capitan. |
Thanks! |
Sweet thank you! |
I didn't try But the alternative way worked for me on macOS Sierra (10.12.4) to uninstall Node v7.9.0. Thank you @nicerobot! |
great! |
thanks.. Great |
I second the "Alternative" route. It works perfectly for El Capitan. Thanks! |
Try with curl, no luck:
|
I also got sudo: cannot execute binary file and suspect it relates to the sudo sudo call (sudo itself runs, except when being run by sudo?) |
I'm on Mac OS X High Sierra v10.13 using NodeJS v6.11.5 LTS installed with package from the official site.
And it works fine! |
Worked fine on the High Sierra v10.13.1 thanks alot! |
Worked for El Capitan v10.11.16. Thank you! |
works fine |
Worked fine in OS X El Capitan v10.11.6. Thank you :) |
This gist is referenced by this SO post, if you run into problems: https://stackoverflow.com/questions/35249204/node-already-installed-its-just-not-linked |
Thanks for the script. In addition to the script, I also had to remove |
Script works fine for me after changing line 23 from # this tries to delete /usr/local/./usr/local/.....
rm -v /usr/local/${i} to # this works fine :)
rm -v ${i:1} Mac OS Mojave 10.14.6 |
macOS Big Sur 11.1 I had to manually delete these after:
Aside from that, seems to have done the trick. |
This comment has been minimized.
Nice work. I forked to edit line #16 as follows:
This looks for the existence of a file (-e) instead of a folder (-d).
Once I did that it worked like a charm. Thanks!