Last active
December 18, 2025 06:44
-
-
Save eliascotto/d12fbeee9b5f79a94e210629d341b6b3 to your computer and use it in GitHub Desktop.
Remove all node_modules folders in a subdirectory
This file contains hidden or 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
| #!/bin/bash | |
| # Check if a folder was passed as an argument | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 <path-to-folder>" | |
| exit 1 | |
| fi | |
| BASE_DIR="$1" | |
| # Find and delete all node_modules directories | |
| echo "Searching for node_modules in: $BASE_DIR" | |
| find "$BASE_DIR" -type d -name "node_modules" -prune | while read -r dir; do | |
| echo "Removing: $dir" | |
| rm -rf "$dir" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment