npkill — The Easy Solution to Delete node_modules With Style
A Node.js open-source tool
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
Therefore, I’m very happy to announce 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.
$ npm i -g npkill
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.
Warning: In future versions, some commands may change
- Search the
node_modulesdirectories in your
npkill -d ~/projects# other alternative:
2. Automatically delete all
node_modules that have snuck into your backups:
npkill -d ~/backups/ — delete-all
In this piece, I’ve covered two important topics:
- This amazing tool, which is very helpful for managing our
- 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.