If you attempt to delete the node_modules folder on Windows, you may have trouble for a variety of reasons. In some cases, for example, the folder nesting within the directory creates folder names that are too long. You might also get the annoying Folder Access Denied message stating, "You'll need to provide administrator permission to delete this folder".
The solution I use is to install RimRaf globally with npm and then use it to delete the folder. RimRaf is an implementation of the UNIX/LINUX command rm -rf for Node, which removes directories and their contents recursively. First, enter this command to install RimRaf from npm:
Once it is installed, you can use the following command from within the project directory that contains the node_modules folder.
Top comments (1)
Sometimes it is not possible to delete everything. In this case there is most likely a process or application running that blocks the files or folders to delete.
It might be the IDE running a node.js process as a child. In this case kill all node.js processes:
Or forced:
This also helps if some node application was not killed by a stopped or crashed terminal/application.