'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?
Solution 1:[1]
From you project folder use following command to delete it:
rd .\node_modules\ /s /q
Solution 2:[2]
I use to have the same issue, taking hours to achieve the deletion until I found this workaround:
Select the node_modules folder. Do this with the file explorer.
Open Powershell as admin: press Alt+F, then S, then A.
Wait and accept to open Powershell as admin
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
/fswitch to force the deletion of read-only files. The/qswitch enables quiet mode. The/sswitch 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> nuldisables the console output improving performance and speed.
Wait for the process to take action.
Now go up one level in the directory with
cd...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_modulesis 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:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Paul |
| Solution 2 | Pizaranha |
