Remove node_modules folder on Windows without errors

I sometimes get errors when I run npm install for my Gulp or Grunt projects. To retry I need to remove the node_modules folder and sometimes that causes problems as when you are on Windows. I had a look around and found a Git repository named rimraf.

To remove a node_modules folder on your system, first install rimraf globally

npm install rimraf -g

Then, navigate to the folder just above the folder you want to remove and run

rimraf node_modules

…and the node_modules folder will be removed. This will of course work for other folders than the node_modules as well.

It is almost as simple as it should have been in Windows…

Leave a Reply

Your email address will not be published. Required fields are marked *