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

Brian is a software architect and technology leader living in Niagara Falls with 13+ years of development experience. He is passionate about automation, business process re-engineering, and building a better tomorrow.

Brian is a proud father of four: two boys, and two girls and has been happily married to Crystal for more than ten years. From time to time, Brian may post about his faith, his family, and definitely about technology.