Delete Node Modules Like a PRO

Mar 11 20243 minutes
Delete Node Modules Like a PRO

You might have heard the joke that node_modules is the heaviest object in the universe.

So node modules are good or bad, I do not know maybe it’s bad if it’s so much hated (jk) , one of the reasons it’s hated is that it takes too much space and it takes too much time to delete, but luckily we are saved by these tricks which helps us to delete node modules in no time.

#Method 1: rmdir

The rmdir command is used to remove a directory, and thus we can use it our benifit while deleting node_modules.

It deletes the whole folder in just a blink fo eye, to delete node_modules navigate to your project directory and run the follwing comand.

rmdir /s /q node_modules

In this command /s is used to delete all subfolder and files including the node_modules folder itself and /q stands for quite means no futher prompts will be given before deleting everything, Without the /q flag, the command might prompt the user for confirmation before proceeding with the deletion.

#Method 2: VS code delete button

This method is for Visual Studio Code users other editors might also have similar feture.

The delete button is very efficient if you are using VS Code, its even faster and convinient than rmdir

To delete the node modules just select node_modules folder and press delete key or right click on the node_modules and click on the delete button.

image from

#Method 3: NPKILL

NPKILL is a commandline tool which scans the whole drive and show the size and age of the node_modules folders along with full path the node_modules folder is located in, it gives very siple interface to delete node modules.

To use NPKILL you can install if using npm i -g npkill, open a terminal/ command prompt in the drive that holds your most of the npm projects and run npkill.

Other way is to simply run npx npkill from the terminal and if you are using it for the first time it will ask you to install the npkill for that you just have to press ENTER.

image from

Use UP🔼 and DOWN🔽 arrow key to navigage to the directories list and use SPACEBAR to delete the node_modules folder in current highlighted directory.

This is one of the most convinient methods so far as it helops to clean the whole drive form single interface.

I hope you found this tutorial helpful, stay healthy keep coding.