One of my happiest memories related to software development was when I developed and distributed my first project among my 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, since 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 in old floppies, kept in old boxes somewhere in my parent’s house.
Nowadays, I teach developers and I’m constantly encouraging my students to give visibility to all their projects, and to rely on the community, since it is there where they will find the best colleagues, outside the classroom. The story I previously told would have gone very differently if it had happened today, since the first thing I would have done is to publish my project on all social networks, and find a good mentor to learn from her/him.
Although you can’t go back in time, I am pleased to present a project developed by two of my former vocational training students, which is published on GitHub. I think it is a great contribution to the community.
This tool solves a traditional problem that us node.js developers have when we install a large set of dependencies in our 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) have developed an npm package which allows management of our old and heavy node_modules folders. 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. Yay!
Before to explain the easiest steps to get this essential tool, I’m going to show a GIF in which I’ve been using this tool in my laptop to save more than 1 GiB over a work folder.
$ npm i -g npkill
npkill
By default, npkill will scan for node_modules starting at the path where npkill command is executed.
Move between the listed folders with ↓ ↑, and use Del to delete the selected folder.
Warning: In future versions some commands may change
1. Search node_modules directories in your projects directory:
npkill -d ~/projects
# other alternative:
cd ~/projects
npkill
2. Automatically delete all node_modules that have sneaked into your backups:
npkill -d ~/backups/ --delete-all
In this post, I’ve shown you two important topics:
Originally published at https://carloscaballero.io on 8 August, 2019.