Uninstall nodejs from Mac


SUBMITTED BY: antfuentes87

DATE: Nov. 25, 2015, 12:47 a.m.

FORMAT: Text only

SIZE: 957 Bytes

HITS: 786

  1. #!/bin/sh
  2. (( ${#} > 0 )) || {
  3. echo 'DISCLAIMER: USE THIS SCRIPT AT YOUR OWN RISK!'
  4. echo 'THE AUTHOR TAKES NO RESPONSIBILITY FOR THE RESULTS OF THIS SCRIPT.'
  5. echo "Disclaimer aside, this worked for the author, for what that's worth."
  6. echo 'Press Control-C to quit now.'
  7. read
  8. echo 'Re-running the script with sudo.'
  9. echo 'You may be prompted for a password.'
  10. sudo ${0} sudo
  11. exit $?
  12. }
  13. # This will need to be executed as an Admin (maybe just use sudo).
  14. for bom in org.nodejs.node.pkg.bom org.nodejs.pkg.bom; do
  15. receipt=/var/db/receipts/${bom}
  16. [ -e ${receipt} ] && {
  17. # Loop through all the files in the bom.
  18. lsbom -f -l -s -pf ${receipt} \
  19. | while read i; do
  20. # Remove each file listed in the bom.
  21. rm -v /usr/local/${i}
  22. done
  23. }
  24. done
  25. # Remove directories related to node.js.
  26. rm -vrf /usr/local/lib/node \
  27. /usr/local/lib/node_modules \
  28. /var/db/receipts/org.nodejs.*
  29. exit 0

comments powered by Disqus