sudo npm uninstall npm -g
brew uninstall node
Then
sudo rm -rf /usr/local/lib/dtrace/node.d /usr/local/lib/node_modules /usr/local/bin/npm /usr/local/bin/nodemon /usr/local/bin/node /usr/local/include/node ~/.npm* ~/.node* /usr/local/share/man/*/node* /usr/local/share/man/*/npm*
Which removes the following
/usr/local/lib/dtrace/node.d
/usr/local/lib/node_modules
/usr/local/bin/npm
/usr/local/bin/nodemon
/usr/local/bin/node
/usr/local/include/node
~/.npm*
~/.node*
/usr/local/share/man/*/node*
/usr/local/share/man/*/npm*
Thanks for this script! It worked for me to uninstall node
14.17.1
from my mac! I only needed to exclude/usr/local/bin/nodemon
from the list since this directory doesn't exist.