Skip to content

Instantly share code, notes, and snippets.

@chernjie
Created January 17, 2025 03:08
Show Gist options
  • Save chernjie/7025ca204c396b29dd0dc6c2073902d6 to your computer and use it in GitHub Desktop.
Save chernjie/7025ca204c396b29dd0dc6c2073902d6 to your computer and use it in GitHub Desktop.
Remove redundant NPM modules
#!/usr/bin/env bash
# @author CJ <[email protected]>
removeRedudantModules() {
jq < package.json '.'$1' | to_entries | map(.key)[]' -r |
while read i
do git grep -l $i |
wc -l |
xargs test 2 -ge && echo $i
done |
xargs npm remove
}
removeRedudantModules dependencies
removeRedudantModules devDependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment