One stop solution to deleting node modules.

Syed Muhammad Haris
3 min readMar 26, 2023

Are you tired of manually deleting node_modules folders from your projects? You’re not alone. These folders can be surprisingly heavy, taking up valuable space on your hard drive and slowing down your development process.

Photo by Pankaj Patel on Unsplash

Node.js projects often rely on third-party dependencies, which are installed in the node_modules directory. Over time, this directory can become bloated, especially if you have multiple projects. The size of node_modules can vary depending on the number and size of the packages you’re using. In some cases, it can take up hundreds of megabytes or even gigabytes of disk space.

Photo by Moritz Kindler on Unsplash

Manually deleting node_modules folders can be a time-consuming and frustrating process. You need to navigate to the project directory, locate the node_modules folder, and delete it. If you have multiple projects, this can quickly become overwhelming. Plus, it’s easy to accidentally delete the wrong folder, which can cause issues with your project.

NPKILL COMMAND

That’s where npkill comes in. This npm package provides a simple and intuitive way to find and delete node_modules folders from your project’s root directory. With npkill, you can easily reclaim disk space and keep your projects running smoothly.

In the rest of this blog post, we’ll take a closer look at how npkill works and how you can use it to manage node_modules folders in your Node.js projects. This npm package provides a simple and intuitive way to find and delete node_modules folders from your project’s root directory. Here’s how to use it:

Install npkill globally using npm by running the following command in your terminal:

npm install -g npkill

Navigate to the root directory of the project(s) you want to clean up.

Type npkill in your terminal and press Enter. npkill will search the current directory and its subdirectories for node_modules folders.

Use your arrow keys to navigate through the list of folders displayed by npkill. You can select a folder by pressing the space bar.

Once you’ve selected the folders you want to delete, press Enter to confirm your selection.

npkill will delete the selected folders, freeing up disk space on your system.

It’s important to note that npkill will permanently delete the selected folders, so be sure to double-check that you’ve selected the correct ones. You can also use the -d flag to preview the files that would be deleted without actually deleting them.

In conclusion, npkill is a useful tool for managing node_modules folders in your Node.js projects. It saves time and reduces the risk of human error, making it an essential addition to your toolkit. Give it a try and see how much disk space you can reclaim!

Found this blog useful?

Make sure to follow me:

Github: https://github.com/harrylovescoding

Linkedin: https://www.linkedin.com/in/syedmuhammadharis

--

--

Syed Muhammad Haris

Hey there! I am Haris, a software student based in Karachi, Pakistan.