Skip to content

Instantly share code, notes, and snippets.

@josethz00
Last active January 26, 2024 18:59
Show Gist options
  • Save josethz00/0bae6e5ef4d6eb9be72ce59b82b23c58 to your computer and use it in GitHub Desktop.
Save josethz00/0bae6e5ef4d6eb9be72ce59b82b23c58 to your computer and use it in GitHub Desktop.
delete all node_modules in the system
#!/bin/bash
echo "Searching for node_modules directories..."
# Assuming NVM is installed in the default location, update this if you have a custom NVM directory
NVM_DIR="$HOME/.nvm"
# exclude nvm
find $HOME -path $NVM_DIR -prune -o -name "node_modules" -type d -print | while read dir; do
echo "Deleting $dir..."
rm -rf "$dir"
done
echo "All node_modules directories have been deleted."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment