DEV Community

Cover image for Too many node_modules and not enough space? Let's solve that.
shaya
shaya

Posted on

Too many node_modules and not enough space? Let's solve that.

While we hack away at all the JavaScript projects and codebases we're working with, something more sinister accumulates... more often unknowingly.

Yes, I'm talking about node_modules. The ones that drain all your pc's life force disk space. Those beautiful snippets of code that we once so easily imported, soon become the nightmare fuel of developers.

But not to worry, it's not all gloom and doom.

Today, I came across an informative short clip by Fireship that blew. my. mind.

It's intuitive, simple, (might need a module installation to work - oops!) but damn it does the job. Say goodbye to all that unnecessary disk clog.

Step 1:

Open your terminal. Enter this command:
npx npkill

Step 2:

You should see this pop up:
Alt TextEnter y to allow installation of npkill.

Step 3:

You should now see this on your terminal:
Alt Text

A juicy list of culprits just waiting to be deleted!


Now all you need to do is move down the list of modules via the spacebar and press space to delete any (or all if you've accumulated a ton like me).
Press escape to leave once you're finished.

Your pc can finally ✨breathe✨.

Hope you had your mind blown too.

Top comments (0)