Go away node/npm

If you haven’t found a use for this script that uninstalls the second largest junk in the world next to Mac/iOS updates, you are either lazy or scared of breaking things.  I am neither, so I polished this script from the different versions you will find on the internet. Oh, I am talking about node/npm.

Happy cleaning!

dump_dir_name="node_junk_`date +%s%N`"
This uninstaller moves all the node/npm files and folders to ${dump_dir}.
Happy cleaning!
# The main binaries / executables
"/usr/local/bin/npm" \
"/usr/local/bin/node" \
# Other bin stuff \
"/usr/local/bin/node/" \
"/usr/local/bin/node-gyp" \
# lib \
"/usr/local/lib/node/" \
"/usr/local/lib/node_modules/" \
# local \
"/usr/local/include/node/" \
"/usr/local/include/node_modules" \
# Home \
"~/.npm" \
"~/.node-gyp/" \
"~/.node_repl_history" \
# The n npm module
"/usr/local/n/" \
# opt \
"/opt/local/bin/node" \
"/opt/local/include/node/" \
"/opt/local/lib/node_modules/" \
"/usr/local/share/doc/" \
"/usr/local/share/systemtap/tapset/node.stp" \
# man \
"/usr/local/share/man/man1/node*" \
"/usr/local/share/man/man1/npm*" \
mkdir -p "${dump_dir}"
for p in ${paths[@]}
if [ -n "$p" ]; then
echo "\t» Moving $p"
sudo mv "$p" "${dump_dir}"
echo "\nUninstalled node/npm successfully. (Junkyard: ${dump_dir}"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.