How to Delete node_modules on Windows

Sharing is Caring

Deleting node_modules and reinstalling modules is usually one of the first troubleshooting mechanisms when things go strangely wrong with a project. For example, it suddenly stops building and you haven’t made any changes.

Deleting node_modules on Windows 7 and Windows 10 can be a frustrating experience if you try to do it from Windows Explorer or Command-Line because the file path names tend to get really long. Deleting from Windows Explorer usually fails but doesn’t say why and the terminal will eventually give a permissions error if it even says anything.

What I tend to do use is git bash or bash now that it’s available natively and run the following command from the root of my project:

it will take a few minutes to run but it will eventually succeed and then I usually reinstall them by just simply doing “npm i” in the root.

Sharing is Caring