DEV Community

Cover image for NPkill - Let's get rid of unused node_modules
Giuliano1993
Giuliano1993

Posted on

NPkill - Let's get rid of unused node_modules

Good morning everyone and happy MonDev! ☕

How is September going? Any new "developments"? 😏

As I already told you, this period is really intense for me and I am very busy with work projects, which is leaving me very little time for personal ones 🥲

However, among the moments I manage to recover, I have almost finished the new sections of my website where I will finally be able to insert all the articles and newsletter releases, every week, so as to have an organized space where you can find everything!

I am really satisfied with how it's turning out and I can't wait to share it with you!

But talking about projects, work-related or personal ones, how many do you have on your computer? How many for work, personal use, or just various experiments? Projects that may have been there untouched for who knows how long.

Well, many of these projects probably have one thing in common. A heavy node_modules folder inside, forgotten there for a long time.

From time to time, it would be good to do some cleaning and give our disk some breathing room. To help us with this rather tedious task, today's tool comes to our aid: npkill.

Npkill is a simple command launchable via npx that scans your disk looking for all node_modules folders, tells you how much space they occupy, and allows you to choose which ones to delete.

Launching it in the basic version is very simple: npx npkill. The command will be downloaded and executed, and you will immediately have a complete list to scroll through using the arrow keys. Whenever you find a folder that can be deleted, just press SPACE to delete it.

However, we know that by now node is behind many programs we use, like vscode. It might be a good idea not to see ALL the node_modules folders you have locally.

So my advice to make the most of this utility is to launch it by choosing the folder to search in, for example, the folder where you keep all your projects:

npx npkill -d 'projects'
Enter fullscreen mode Exit fullscreen mode

There are other options in the documentation, and the project, as you can imagine, is open source and looking for contributors, so if you have ideas, go check it out ;)

What do you think, do you find it useful? Will you try to use it?

Articles of the week

I hope I gave you some interesting ideas!

As always, we'll talk next week!

Happy Monday and Happy Coding 0_1

Top comments (0)