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 '{}' +

Related Quick Tips

Published 23 May - 2020

Use javascript fetch to post to a Phoenix controller

As in the case with Rails, Phoenix also has protection against cross site request forgery (crfs). If you want to post to a controller from a javascr..