Skip to content

@nicerobot /README.md
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Mac OS X uninstall script for packaged install of node.js

To run this, you can try:

curl -ks https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh | bash

I haven't tested this script doing it this way but i run a lot of my Gists like this so maybe this one'll work too.

Alternatively,

curl -ksO https://gist.github.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).
# Verify the bom exists, otherwise don't do anything
[ -e /var/db/receipts/org.nodejs.pkg.bom ] || {
echo 'Nothing to do.'
exit 0
}
# Loop through all the files in the bom.
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \
| while read i; do
# Remove each file listed in the bom.
rm /usr/local/${i}
done
# Remove directories related to node.js.
rm -rf /usr/local/lib/node \
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*
exit 0
@omarrr

Nice work. I forked to edit line #16 as follows:

 [ -e /var/db/receipts/org.nodejs.pkg.bom ] || {

This looks for the existence of a file (-e) instead of a folder (-d).

Once I did that it worked like a charm. Thanks!

@Bauepete

Thanks.

@mhulse

Great script, thanks! Just FYI to anyone out there new to running shell scripts: I had to run $ chmod u+x uninstall-node.sh and then $ ./uninstall-node.sh before it worked for me. Also, there's a question on Stack related to this code if it is of help to anyone (might be a good place for comments, seeing as how GitHub does not notify anyone (at this time) when comments are posted to Gists).

@ghost
Unknown commented

Had to use mhulse's method to get it to work, thanks though!

@Jurawa

Awesome. Worked great, thanks!

@tezca-antisol

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

@roman

What is the purpose of (( ${#} > 0 )) ?

@denji

node 0.11.x forgot delete /usr/local/share/systemtap
if empty (/usr/local/share/systemtap + /usr/local/share/systemtap/tapset)

nodejs/node-v0.x-archive#6141

@taoeffect

@roman, it's a hack to skip the first block on the next run.

@ravs

Thanks, nice stuff.

@djdiaz

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.

@8bitbliss

Thanks, worked great. And thanks for the tip mhulse.

@ivancevich

Excellent job. Thanks!

@lrestifo

Worked a treat for me just by saving the script locally and chmod 755 the resulting file

@poliveira89

For now, it seems to be executed successfully! :+1: (For me)

@TanayGahlot

Dint work for me :(

@alexserver

/usr/bin/sudo: /usr/bin/sudo: cannot execute binary file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.