Npkill v0.12.0

Cover with screenshot of npkill v0.12.0 interface
Cover with screenshot of npkill v0.12.0 interface
Other languages: Español

It’s been more than a year since the last update of npkill. In fact, this new version almost coincides with the anniversary of the first functional one, v0.1.3 (two failed attempts before achieving a version that at least started 🙃).

Today I have released version v0.12.0 and I’m going to tell you about all the new features it brings.

In case you don’t know it yet, npkill is a CLI tool that allows you to find all the node_modules living on your system, along with useful information such as the last time they were used, or the space they occupy so you can delete them and free up space on your disk.

You can try it out by simply running npx npkill.

What’s new

Visual feedback when updating values

This affects the Releasable space and Space saved indicators. Now, every time the values are updated (either because a new result is found or a directory deletion is completed), they will briefly change color to highlight the increase.

Pending tasks

Deleting node_modules can take longer than expected, especially if there are many results on the screen. This can cause npkill to be closed prematurely.

To solve this problem, an indicator has been added to show how many directories are being deleted at that moment.

Pending tasks counter *sm

Open the project directory in the file explorer

Thanks to @AhsanAyaz it is now possible to open the project directory with o (pen).

This will open the project path in your preferred file explorer so you can take a look and decide if you need that node_module or not.

New parameter --dry-run

When running npkill with this argument, nothing will be deleted. This allows you to test various aspects without affecting the files.

Npkill will display a warning when started in this mode. The time it will take to “delete” the results will be random.

Dry run badge *md

The return of --delete-all

The --delete-all/-D option makes npkill automatically delete all the node_modules it finds. Very useful when you have tons of them and don’t feel like giving your thumb a workout by deleting them one by one.

This option was disabled shortly after the release of v0.3.0 as a preventive measure due to some issues we were detecting. Now that some time has passed and the overall functionality has been refined, this feature has been brought back. It’s something the community had been missing for a long time.

Recommendations for using this:

  1. Accompany the command with -x to exclude those node_modules that might be needed by other applications.
  2. If the workspace is very large, preview the node_modules to be deleted with --dry-run to make sure you don’t delete something you shouldn’t (like a dependency for a program such as Spotify, for example).

In any case, an extra confirmation will always be required before starting, unless -D is accompanied by the -y argument.

Warning --delete-all *md

Minor design changes

  • The indicators section has been moved 1 row up.
  • The yellow header, which previously only contained the usage instructions, has now been expanded to occupy the entire width of the terminal.

Interestingly, this last change was one of the most difficult ones. Not technically, of course, but rather because of the nostalgia for being one of the elements that had remained virtually unchanged since the beginning of the project. But well, we can’t live tied to the past, and I think it was a change for the better.

Anyway, sooner or later with the upcoming arrival of the much-anticipated v1.0.0, many more things will change. Better get used to it.

To conclude…

Although only node_modules have been mentioned, the truth is that npkill allows you to search for any type of directory, such as .angular, .cache, or dist. To do this, run it with the parameter -t "<target>".

If you like npkill, don’t forget to give it a 🌟 on the project on GitHub!