Skip to content

Instantly share code, notes, and snippets.

@PCreations
Forked from nicerobot/README.md
Last active March 21, 2016 09:36
Show Gist options
  • Save PCreations/6df8b04cbf68c10a9b3c to your computer and use it in GitHub Desktop.
Save PCreations/6df8b04cbf68c10a9b3c 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/PCreations/6df8b04cbf68c10a9b3c/raw/445b87d1d4550b336353cec77720502fd6f42022/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/PCreations/6df8b04cbf68c10a9b3c/raw/445b87d1d4550b336353cec77720502fd6f42022/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.
echo "rm -v /usr/local/${i}"
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