A Node.js open-source tool

Carlos Caballero
Aug 13 · 3 min read

One of my happiest software development memories is when I developed and distributed my first project among friends and family.

Although I learned to develop long before then, it was in 2003 when I developed the classic game Arkanoid in assembler.

Of course, this game couldn’t be distributed online as we had no internet at home, GitHub didn’t exist, and, in my particular case, I didn’t know any social networks for developers.

Today, this story is a beautiful memory stored in my mind… and possibly on old floppies…

Nowadays, I teach developers and I’m constantly encouraging my students to give visibility to all their projects and to rely on the community as it is there where they will find the best colleagues outside the classroom.

The story in the previous paragraph would have gone very differently if it had happened today. The first thing I would have done is publish my project on social networks and find a good mentor to learn from.

Although you can’t go back in time, I am pleased to present a project developed by two of my former vocational training students. I think it is a great contribution to the community.

This tool solves a traditional problem that Node.js developers have when they install a large set of dependencies in projects.

The number of node_modules folders in our computer grows as we develop more projects. More often than not, we don’t remember where the node_modules folders are stored, so it is very difficult to find and delete them.

These two students (now developers) developed an npm package which allows management of our old and heavy node_modules folders.

Therefore, I’m very happy to announce npkill.


npkill

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

Before we explain the easy steps to get this essential tool, I’m going to share a GIF with you, where I’ve used this tool on my laptop to save more than one GiB on a work folder.


Installation

$ npm i -g npkill

Usage

$ npkill

By default, npkill will scan for node_modules, starting at the path where the npkill command is executed.

Move between the listed folders with ↓ ↑ and use the Del key to delete the selected folder.


Options

Warning: In future versions, some commands may change


Examples

  1. Search the node_modules directories in your projects directory:
npkill -d ~/projects# other alternative:
cd ~/projects
npkill

2. Automatically delete all node_modules that have snuck into your backups:

npkill -d ~/backups/ — delete-all

Conclusions

In this piece, I’ve covered two important topics:

  1. This amazing tool, which is very helpful for managing our node_modules.
  2. You are also able to develop an awesome project. A few months ago, they were in class discovering fundamental concepts, such as promises, hoisting, design patterns, or tooling. Remember that you can do anything too.

My recommendation is to visit the npkill official repo, read the code, and start helping them in this fun adventure of creating open-source content.


Better Programming

Advice for programmers.

Carlos Caballero

Written by

Hi! My name is Carlos Caballero and I’m PhD. in Computer Science from Málaga, Spain. Teaching developers and degree/master computer science how to be experts!

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade