node.js npm windows-7

How to Delete node_modules – Deep Nested Folder in Windows


Upon trying to remove the node_modules directory created by npm install:

The source file name(s) are larger than is supported by the file
system. Try moving to a location which has a shorter path name, or try
renaming to shorter name(s) before attempting this operation

I also tried shift + delete and still having the same issue.


  • try renaming to shorter name(s) before attempting this operation

    – SLaks

    Jan 27, 2015 at 16:30

  • 3

    Thanks for your suggestion,@SLaks! I should have mentioned that I tried that too, but the files and dirs are many and deep, it has things like C:\Users\my_user_name\projs\backend\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin\node_modules\bin-wrapper\node_modules\bin-check\node_modules\executable\node_modules\meow\node_modules\camelcase-keys\node_modules\… and it goes on. It’s impractical to rename files manually and I hope there will be easier ways without writing a program

    – leoh

    Jan 27, 2015 at 16:47

  • 3

    Webstorm can delete all.

    – ozzimpact

    Dec 22, 2015 at 11:54

  • I used the Long Path Fixer tool and successfully removed this “.meteor” folder. (

    – Doan Vu

    Aug 2, 2018 at 5:16

  • RUN INSTALL, npm install rimraf -g, RUN DELETE, rimraf node_modules

    Aug 6, 2018 at 6:38


Since this the top google result, this is what worked for me:

Update, if you have npm v5, use npx:

npx rimraf ./**/node_modules

Otherwise install RimRaf:

npm install rimraf -g

And in the project folder delete the node_modules folder with:

rimraf node_modules

If you want to recursively delete:

rimraf .\**\node_modules

[ ]


  • 17

    I’m the author of the blog post. @olefrank: this tends to happen when you try to delete the whole folder (not just node_modules), and also if you happen to have the folder opened in an Explorer window. usagidon, thanks for linking the original source.

    – Nikola

    Jul 23, 2015 at 13:33

  • 2

    That won’t be useful if you don’t have NodeJS, or you’re trying to delete the global modules of NodeJS after uninstalling it (that is why I had to use robocopy)

    – Zorgatone

    Mar 2, 2016 at 12:45

  • 2

    I’ll add my 2 cents here to be a bit more specific to the question. You can delete all the node_modules folders recursively (using globbing pattern) like this: rimraf .\**\node_modules

    – Artif3x

    Mar 1, 2019 at 15:22

  • 2

    One-liner: npx rimraf node_modules. Npx is included with NPM 5.2+ and is a eXecutor for npm packages, which automatically downloads missing npm packages.

    – andy

    Nov 18, 2019 at 12:42

  • 1

    @Artif3x ‘s commnent should be marked as the best answer loll! thanks for the tip for deleting recursively 🙂

    Dec 24, 2019 at 1:09


I’ve simply done that by using Winrar, this may seem a strange solution but working very well.

  • right click on node_modules folder
  • select Add to archive ... from the menu.
  • Winrar dialog opens
  • just check the option delete files after archiving
  • Don’t forget to delete the node_modules.rar after finished.

This also works with 7Zip


  • 7

    wow this is sneaky! +1 Been using robocopy tho apparently this has been fixed with new npm or something.

    – erp

    Jun 15, 2016 at 23:38

  • 1

    @ChrisS How does it workt with 7Zip? Especially when using the GUI!

    – bennos

    Feb 27, 2018 at 10:59

  • 6

    In 2016 (and especially 2018) you shouldn’t have to be this clever to delete a bunch of files.

    – webelo

    Nov 15, 2018 at 14:55

  • yeah, you’d think if winrar can figure it out they could get the window shell to do it…..

    – jonesy827

    Sep 18, 2020 at 6:05

  • @bennos, it works similarly with 7-Zip. Choose Add to Archive to open the GUI. There is an option Delete files after compression.

    Sep 18, 2020 at 9:15


DELETE only by using DOS command without any installation:

Create an empty folder “test” on C or D drive and use following DOS command

robocopy /MIR c:\test D:\UserData\FolderToDelete > NUL

After completing above command, your folder will be empty, now you can delete the folder.

Don’t worry your test folder will always be empty, so you can delete it at any time.


  • 14

    best answer, because you don´t need to install anything

    – andyrandy

    Dec 20, 2015 at 11:33

  • 1

    After trying rimraf and adding a network folder, this is the cleanest solution I’ve found. Thanks for sharing this.

    – danyim

    Feb 11, 2016 at 22:21

  • 1

    great solution; easy.

    – bob.mazzo

    May 16, 2016 at 15:15

  • 2

    I just made a minor addion: > NUL. When I just tried this, it was being throttle by the console, and was going to take 15 minutes or more. With the redirection in place, it finished in about 2

    Nov 3, 2016 at 19:15

  • It’s funny that in order to delete some JS files, you need yet another JS library.

    – linuxunil

    Jul 23, 2018 at 8:39