Last active
February 19, 2019 16:38
-
-
Save vivekragunathan/15c8b3b408c8015683a8d5fcf97cbf2f to your computer and use it in GitHub Desktop.
Script to uninstall node and npm completely from your mac!
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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment