Quickly remove all node_modules folders from your system to free up disk space
Whenever, we are working with React, Angular, Nodejs or any other library or framework, we always need to create a node_modules
folder which takes up a lot of space and we don’t bother to remove the node_modules folder once our job is done.
So we end up creating many node_modules
folders in various project folders which takes up a lot of hard-disk space on our filesystem.
Today we will see a very helpful command which scans our file system and easily allows us to remove the node_modules
folders in a single click within seconds.
Installation
You actually, don’t need to install the package to use it.
You just need to run it as
npx npkill
npx allows to run npm commands without installing the package.
You can however, install the npkill package if you really need to install it using
npm install npkill -g
and now you can just run npkill
command from the terminal from any directory to delete the `node_modules
folder.
Once the list is displayed, you can navigate using arrow keys and delete the specific node_modules directory by hitting spacebar.
To exit out of the list, press q key on your keyboard or Control + C
By default,
npkill
will list out the node_modules folders from the current directory and its subdirectories.
So if you want to delete all the node_modules from your system, you need to execute thenpkill
command from your home or root directory.
Speed
You might think that it will take a lot of time to delete a single node_modules
folder using npkill
, but that’s not true. Actually, it's very fast. within a second the folder will be deleted. So Just give it a try
That’s it for today. Now keep deleting node_modules happily.
I hope you've been enjoying my articles and tutorials I've been writing. If you found them useful, consider buying me a coffee! I would really appreciate it.
Don’t forget to subscribe to get my weekly newsletter with amazing tips, tricks, and articles directly in your inbox here.