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!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dump_dir_name="node_junk_`date +%s%N`" | |
dump_dir="${HOME}/Temp/${dump_dir_name}/" | |
echo "NODE/NPM UNINSTALLER v0.0.1 | |
This uninstaller moves all the node/npm files and folders to ${dump_dir}. | |
Happy cleaning! | |
" | |
paths=( | |
# The main binaries / executables | |
"/usr/local/bin/npm" \ | |
"/usr/local/bin/node" \ | |
# Other bin stuff \ | |
"/usr/local/bin/node/" \ | |
"/usr/local/bin/node-debug" | |
"/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*" \ | |
"/usr/local/lib/dtrace/node.d" | |
) | |
mkdir -p "${dump_dir}" | |
for p in ${paths[@]} | |
do | |
if [ -n "$p" ]; then | |
echo "\t» Moving $p … " | |
sudo mv "$p" "${dump_dir}" | |
fi | |
done | |
echo "\nUninstalled node/npm successfully. (Junkyard: ${dump_dir}" |