Psst. It would be super cool if you could try the new Phoenix Boilerplate!

Try now

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

What are you working on?

If you want, you can send me a link to your Phoenix or Phoenix LiveView project so. Lets connect on Twitter or Linkedin.

- Andreas Eriksson, web developer since 2005

Related Quick_tips

Published 23 May

Use javascript fetch to post to a Phoenix controller

javascriptcsrf

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..