Quick Tip
Delete unused node_module folders
javascript
Tired of all node_modules folders taking up gigabytes of hard drive space? Did you know theres is a command to find and delete them?
If you are like me, you have a lot of projects started in your development folder. And most of these projects has a node_modules folder. And since I don’t work on all of them, I can easily just delete the folders and run `yarn` next time I revisit the project.
First, find out how much space they take up. Run this from your projects folder:
find . -name "node_modules" -type d -prune -exec du -sh '{}' +
784M ./project_1/node_modules
122M ./project_2/node_modules
215M ./project_3/assets/node_modules
...
And then run the delete command to remove all of them.
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +