Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete node_modules folder quickly?

When I want to delete a node_modules folder it takes ages when I delete it using Windows Explorer. How do I delete faster?

like image 866
Paul Avatar asked Jul 26 '26 13:07

Paul


1 Answers

I use to have the same issue, taking hours to achieve the deletion until I found this workaround:

  1. Select the node_modules folder. Do this with the file explorer.

  2. Open Powershell as admin: press Alt+F, then S, then A.

  3. Wait and accept to open Powershell as admin

  4. Paste this command and press Enter: del /f/q/s *.* > nul.

WARNING

Please be sure to be in the folder node_modules. I mean, that the terminal path ends with ...\node_modules.

In the above command, we use the /f switch to force the deletion of read-only files. The /q switch enables quiet mode. The /s switch executes the command for all files in any folder inside the folder you’re trying to remove. Using *.* tells the del command to delete every file and > nul disables the console output improving performance and speed.

  1. Wait for the process to take action.

  2. Now go up one level in the directory with cd...

  3. Finally use this command to delete the node_modules folder rmdir /q/s node_modules

In the above command, we use the /q switch to enable quiet mode, the /s switch to run the command on all the folders, and node_modules is the variable you need to specify to delete the folder you want.


If you get an error with Powershell try other terminals as administrator like Windows Terminal, Command Prompt (cmd) or third party terminals like ConEmu. I made this steps with Cmder and all the deletion was done in just 5 minutes. Off course this duration is variable according to the size of the folder.


References:

pureinfotech.com

ConEmu

Cmder

like image 95
Pizaranha Avatar answered Jul 30 '26 08:07

Pizaranha