Read About my Experience on GDG Cloud Event : - Click here to Read !

Say Goodbye to Unused node_modules with NPKill - paruidev

Say goodbye to unused node_modules with npkill Learn how to save disk space and boost productivity by cleaning up your Node.js projects effortlessly
blog thumbnail

Introduction

Hello everyone, welcome back to another banger post! As the title suggests, today, I will introduce you to NPKill, a powerful tool that will help you save time and free up valuable storage space. If you are a Node.js developer, you probably have multiple projects scattered across your system, each with its node_modules folder. These folders can take up gigabytes of space, even for projects you no longer work on. Instead of manually searching and deleting them, NPKill automates the process efficiently.

A Fun Thought

While writing this article, I couldn’t help but recall the classic node_modules meme—you know, the one where deleting the folder feels like removing a massive chunk of unnecessary weight from your system. It’s amusing how every developer has, at some point, encountered a project where node_modules took up gigabytes of space, only to be rebuilt in seconds with a simple npm install.

node module meme

Let’s dive in and explore how to use NPKill effectively!

What is NPKill?

NPKill is a command-line tool that scans your system for unused node_modules folders and allows you to delete them with ease. It is lightweight, fast, and helps in cleaning up your disk space in just a few clicks.

np kill terminal


Why Should You Use npkill?

  1. Saves Disk Space: Unused node_modules folders can take up gigabytes of space. npkill helps you reclaim that space effortlessly.
  2. Boosts Productivity: Manually searching for and deleting these folders is time-consuming. npkill automates the process.
  3. User-Friendly Interface: npkill provides an interactive CLI (Command Line Interface) that makes it easy to navigate and delete folders.

How to Install and Use NPKill

Now, let’s see how to install and use NPKill step by step.

😅Note: However while I performing this I forgot to take snap shot for the full process, so still I have try to explain the best possible way as always.

Step 1: Install NPKill Globally

To install NPKill, you need to have Node.js installed on your system. Open your terminal or command prompt and run the following command:

npm install -g npkill

This will install NPKill globally, allowing you to use it from anywhere in your system.

Step 2: Run NPKill

Once installed, simply run:

npkill

This will scan your system and display a list of projects containing node_modules folders, along with their sizes.

Step 3: Navigate Through the List

NPKill will show you all node_modules folders found in your system. The interactive CLI allows you to navigate using:

  • Arrow keys to move up and down
  • Enter key to delete a selected node_modules folder
  • Ctrl + C to exit

Step 4: Deleting Unused node_modules

npkill will ask for confirmation before deleting any folders. This ensures you don’t accidentally remove something important. Once confirmed, the selected node_modules folders will be deleted, freeing up space on your system.


Tips for Using npkill Effectively


npkill terminal paruidev

  1. Backup Important Projects: Before running npkill, ensure you have backups of any critical projects.

For advanced usage, you can use NPKill with additional flags:

  1. Use -directory Flag: If you want to scan a specific directory, use the -directory flag followed by the path. For example:

    npkill --directory /path/to/your/projects
  2. Check for Updates: npkill is actively maintained, so make sure you’re using the latest version for the best experience.

  • Skip confirmation:

    npkill -r

    This automatically deletes selected node_modules folders without asking for confirmation.

  • Show hidden folders:

    npkill --hidden

    This displays hidden node_modules folders as well.

Conclusion

If you’re tired of manually cleaning up node_modules folders or dealing with low disk space, npkill is the solution you’ve been waiting for. It’s fast, efficient, and incredibly easy to use. By integrating npkill into your workflow, you can focus more on coding and less on managing dependencies.

So, what are you waiting for? Give npkill a try and say goodbye to unused node_modules today!

For more details, check out the official documentation at https://npkill.js.org/.

For any Query or Paid collaboration mail me at : contact@paruidev.com

Hey! 👋 I’m Pratap, a Frontend Developer with 2+ years of experience crafting digital experiences through code and design. I specialize in frontend web development and UI/UX design, Through this blog…

Post a Comment