paint-brush
npkill — The solution to deleting node_modules easily, with styleby@carlos.caballero.gonzalez
2,283 reads
2,283 reads

npkill — The solution to deleting node_modules easily, with style

by Carlos CaballeroAugust 9th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Numpykill is a tool that allows developers to manage node_modules in their NodeJS projects. The number of node_ modules folders in our computer grows as we develop more projects. It is very difficult to find and delete them, so it is difficult to do so. This tool allows you to list any node_modal 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. Automatically delete all nodes that have sneaked into your backups: nopekill --delete-all/delete.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - npkill — The solution to deleting node_modules easily, with style
Carlos Caballero HackerNoon profile picture

Introduction

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.

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.

Installation

$ npm i -g npkill

Usage

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.

Options

Warning: In future versions some commands may change

Examples

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

Conclusions

In this post, I’ve shown you two important topics:

  1. This amazing tool which will be very helpful to manage our node_modules.You are also able to develop an awesome project. A few months ago they were in class discovering fundamental concepts like “promises”, “hoisting”, “design patterns” or “tooling”. Therefore, remember that you are able to do anything too.
  2. 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.

More, More and More…
- npkill GitHub
- npkill Web

Originally published at https://carloscaballero.io on 8 August, 2019.