DEV Community

Cover image for One command to remove gigabytes of unused `node_modules` data
Lioness100
Lioness100

Posted on

2 1

One command to remove gigabytes of unused `node_modules` data

Programming is just one big cycle. Create or download a project, install your dependencies, build something amazing, and move on to the next one. However, with node.js projects, there's a glaring problem.

Every time you move on to another project, you leave incredible amounts of data in the node_modules folder that you may never use again. This can add up... quite quickly.

NPM is heavier than a black hole meme

Don't despair! There's an easy fix, and it's called npkill.

GitHub logo voidcosmos / npkill

List any node_modules 📦 dir in your system and how heavy they are. You can then select which ones you want to erase to free up space 🧹

npkill logo npkill logo scope

npm Donations Badge npm version NPM

Easily find and remove old and heavy node_modules folders ✨

npkill demo GIF

This tool allows you to list any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space. Yay!

i18n

We're making an effort to internationalize the Npkill docs. Here's a list of the available translations:

Table of Contents

✔️ Features

  • Clear space: Get rid of old and dusty node_modules cluttering up your machine.

  • Last Workspace Usage: Check when was the last time you modified a file in the workspace (indicated in the last_mod column).

  • Very fast: NPKILL is written in TypeScript, but searches are performed at a low level, improving performance greatly.

  • Easy to use: Say goodbye to lengthy commands. Using npkill is as…





It's an easy CLI that provides a user friendly interface to scroll through all of your node_modules folders, and, if necessary, delete some at the click of the button.

Personally, I think it's an incredibly cool and useful tool, and I'm sure you will too! To get started, just type:

npx npkill
Enter fullscreen mode Exit fullscreen mode

And start freeing space!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
foxy4096 profile image
Adzy

Hehe, really if node_modules could be measured it would have so massive gravity that it will attract object from the farest galaxy ever discovered by human being.

Collapse
 
gelatte profile image
Rodrigo Fernando

Really nice!

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post