DEV Community

Discussion on: Remove unused npm modules in less than 30 seconds!

Collapse
 
coolaj86 profile image
AJ ONeal (formerly @solderjs) • Edited

Uninstall all of the unused deps:

npm install -g depcheck

npx depcheck | sed '/Missing/q' | grep '\*' | cut -c 3- | while read my_package; do
  npm uninstall "$my_package"
done
Enter fullscreen mode Exit fullscreen mode

Note: You may want to run npx depcheck again right after, as you may have removed something that you didn't use, but it may have had a dependency that you did use.