How to Delete Node Modules Folder With npkill


Node.js is a JavaScript runtime environment that allows you to run JavaScript outside web browsers, making it a popular choice for developing all kinds of applications. Part of its popularity is due to the plethora of NPM packages out there to ease the developer experience.

However, these packages can consume quite a lot of space on your disk, and you might not want to keep them around after completing the development process. Learn how to clean these unwanted packages from the node_modules folder with npkill.

What Is npkill and How Can You Use It?

npkill is a lightweight NPM package that allows you to easily find and remove old and heavy node_modules folders. Before you get started using npkill, make you have Node.js and NPM installed on your computer.

Running npkill is a pretty straightforward process and does not require you to install any additional dependencies. You can access it by running this command in the terminal:

npx npkill

This command will scan for all the node_modules folders starting at the path where the command was executed and display them along with the amount of space they take up on your disk.

Running npkill on terminal

Using this interactive tool, you can pick the projects that you no longer actively develop and delete the dependency files and folders seamlessly, with just the press of a button.

You can use the arrow keys to move between the listed folders and the Space Bar to delete the selected folder. Once done, use the Q key or Ctrl + C keys to exit the interactive menu.

Stay Cautious While Deleting the Folders

npkill is a handy tool for deleting unwanted files of old projects that you no longer maintain. However, deleting the node_modules folder of active projects will require you to reinstall them before you can run the app again. It's recommended that you proceed with caution while deleting any folder as this action is irreversible.

New to the Node.js ecosystem or transitioning from a different technology? Here's everything you need to know to get started with Node.js development.


What Is the Best VPN for Amazon Fire Stick? 5 VPNs to Consider

Previous article

How to Use Python’s time Module

Next article

You may also like


Leave a reply

Your email address will not be published. Required fields are marked *


Login/Sign up