Delete node_modules on windows

node_modules – Quick how to delete it on Windows systems

Every npm project comes with node_modules folder after installation. It’s all nice and fancy while you’re working on the project, but what happens when you need to delete it?

Say you are moving repositories, renaming folders or just clearing up old stuff. If you are using Windows, chances are that you will get “path too long” or something along the lines.

Windows has 260 characters limit on path files and deleting so many nested folders is impossible with the “delete” function.

How to delete node_modules

Ironically, you need another npm module for that. Now, in order to make it work, you need to have it installed globally. Run the following command:

npm install rimraf -g

After doing this you will have access to the command anywhere on the system. To delete the npm folder just run:

rimraf node_modules

See more on the package’s page.

Thanks to all this you can really feel like a Windows user 🙂 #nohate


One response to “node_modules – Quick how to delete it on Windows systems”

  1. Meghan Mccarty Avatar
    Meghan Mccarty

    I am suggesting to try “Long Path Tool” program.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.