Skip to content

Instantly share code, notes, and snippets.

@hadri3n
Forked from nicerobot/README.md
Created May 11, 2016 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadri3n/de4c96e9595a9de0f6d9fd1a09709e00 to your computer and use it in GitHub Desktop.
Save hadri3n/de4c96e9595a9de0f6d9fd1a09709e00 to your computer and use it in GitHub Desktop.
Mac OS X uninstall script for packaged install of node.js

To run this, you can try:

curl -ks https://gist.githubusercontent.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.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh
chmod +x ./uninstall-node.sh
./uninstall-node.sh
rm uninstall-node.sh
#!/bin/sh
# 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}
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment