Mac OS X – So I have been hit by an issue during uninstall of Node.js on my mac. I encountered some strange behaviour like npm is still their even after having removing it with all this. Below, I gathered all the steps and ways on how to completely delete “native” Node.js installation and also the best way to completely uninstall node + npm.

2First option is to delete the physical files related to Node.js. To do that, follow this simple steps.

  1. Go to /usr/local/lib — delete any node and node_modules
  2. Go to /usr/local/include — delete any node and node_modules directory
  3. If you installed with brew install node — run brew uninstall node in your terminal
  4. Check your Home directory for any local or lib or include folders — delete any node or node_modules from there
  5. Go to /usr/local/bin — delete any node executable

 

1Just in case the above solution does not work, try this additional terminal commands as well.

  1. sudo rm /usr/local/bin/npm
  2. sudo rm /usr/local/share/man/man1/node.1
  3. sudo rm /usr/local/lib/dtrace/node.d
  4. sudo rm -rf ~/.npm
  5. sudo rm -rf ~/.node-gyp
  6. sudo rm /opt/local/bin/node
  7. sudo rm /opt/local/include/node
  8. sudo rm -rf /opt/local/lib/node_modules
  9. sudo rm -rf /usr/local/include/node/
  • Great advice, thanks!

  • ScottyZA

    Worked! Thanks!

  • Kaos

    Thanks.

  • Betsy Dupuis

    May also want to include sudo rm -rf /usr/local/include/node/

    • Vanilton Pinheiro

      Thanks

    • I updated my article. Thanks @betsydupuis:disqus

      • Betsy Dupuis

        Everything else worked great! Thanks for putting this together.

  • hcdave

    That worked perfectly. Thank you so much!

  • Sertaç Onay

    I also deleted /usr/local/lib/node_modules
    sudo rm -rf /usr/local/lib/node_modules

    • You may not include those if it works for you @sertaonay:disqus. Thanks!

  • BD

    Possible folders/files to add to remove:

    /usr/local/share/doc/node/
    /usr/local/share/systemtap/tapset/node.stp

  • Thanks for making the list – cheers.

  • keslo

    Great!

  • Keenan Wells

    What all counts as a node executable in /usr/local/bin ?
    Maybe a dumb question, but I removed nodemon, node-debug, express, and other such files.
    Are other files such as webpack, or flow also node executables?

  • Erik

    Thanks! Worked great!

    • Your welcome. Thanks for dropping by @er@disqus_2YYQfJrEFw:disqus

  • Reiner Saddey

    Hi Benjie, I’m currently experimenting with a different approach: Instead of trying to find and remove any left-overs, why not try to confine Node.js within a Docker container? I took a first humble (I’m new to both Node.js and Docker) step for Ionic 2 PWAs, see https://blog.saddey.net/2016/07/03/using-docker-to-create-ionic-2-pwa-developer-environment/

    Might this approach be enhanced to provide painless usability? If yes, it would have the added benefit of sharing a common configuration within teams (regardless of whether the devolper uses OS X, Linux or Windows). Node.js already is available as a Docker image, but it’s targeted towards build and production environments (e.g. airtight istead of permissive – based on Debian).

  • OzzyLovesBabyShampoo

    Wow, I ran all these commands and yet when I run “node -v” I still get back “v6.9.1” …this is absolutely terrible. Why wouldn’t they just have an uninstaller rather than this mess?