{

Quick way to delete node_modules folder on Windows


Sometimes, We want to delete the node_modules folder in windows for a fresh installation of packages.

node_modules contains a nested recursive folder, and the files count is very huge. Delete a node_module folder in windows is not the quickest and is time-consuming because of the following reasons.

Due to this, In Windows, The node_modules files are deleted in two phases.

  • Discovery phase: In this, It calculates the number of files and folder size before deleting the folders and files.
  • Progress status phase: It deletes the files by showing the progress bar from zero to 100%.

You can see the screenshot.

Fast and multiple ways to delete node_modules folder in windows

It does not happen with Linux and macOS, hence, It is the quickest in those OS.

How to delete node_modules quickest and easiest in Windows?

There are many other ways to delete the folder and recursive subfolders.

  1. use the rmdir command One of the easy ways is using command line
RMDIR node_modules /S

Running the above command asks prompt dialog to take input, if you say YES, it deletes the folder.

A:\work\angular-convert-examples>RMDIR node_modules /S
node_modules, Are you sure (Y/N)? Y

In another way, without prompt, use /Q option

RMDIR node_modules /S /Q

It deletes the node_modules folder completely,

Does it the fastest? No, It takes some time to delete the recursive folder.

Then, How do you delete a folder quickly and easily?

  1. use PowerShell recursive command

if you are still want to do with the command line recursively,

Open Powershell and run the below command

rm node_modules -force -recurse

It is faster compared with the rmdir option.

  1. use rimraf package

rimraf package is the node package

run below command globally.

npm install -g rimraf

Once installed, run the below command to delete node_modules.

rimraf node_modules

Conclusion

To Sum up, Learn different ways to delete node_module in windows.

rimraf node package is the best and quick way to do it.

THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.