2

Following this guide, after execute the command yo webapp a folder named node_modules is created. I want to delete that folder but I can't do it neither using command line or Windows file explorer because the path is too long. How I can delete this folder?

Error message at console:

rmdir : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

3 Answers3

0

Specify the path using Extended Length Path syntax, e.g. \\?\C:\Path\to\an\existing.file.

Also, I successfully used Total Commander to delete a directory in a long path.

Community
  • 1
  • 1
David Ching
  • 1,903
  • 17
  • 21
  • Thanks for your reply. Can you be more specific? I tested with `rmdir \\Laptop\C:\Users\USERNAME\tmp\my-yo-project /s` and it did not work. –  Mar 11 '15 at 23:35
  • What about `rmdir \\?\C:\Users\USERNAME\tmp\my-yo-project /s` – David Ching Mar 12 '15 at 00:03
  • 1
    That command produce another error, do you test that command? or you re just guessing? –  Mar 12 '15 at 00:16
  • It works for me to delete `d:\temp\todelete` I typed `rmdir \\?\d:\temp\todelete` and it worked. This is on Win 7 x64. – David Ching Mar 12 '15 at 00:26
  • Pls, note that I'm not asking for a command to delete a normal folder, I'm asking for a command (or whatever) to delete a folder that can't be deleted using windows explorer because the path is too long and the normal windows command gave the error that I had put in my original question. Your command worked because you don't used the `/s` and because you were not trying to delete a super deep directory tree. –  Mar 12 '15 at 00:31
  • 1
    I see what you mean. I was thrown off by your shorter example starting with `\\Laptop` in your comment . [This article](http://stackoverflow.com/questions/3591840/are-extended-length-paths-safe-to-use) implies you can at least get Explorer to show the long path, but I could not get it to work. [Total Commander](http://www.ghisler.com/) is a tool I used just now to delete the long path I had created to experiment with your case, and you may find it helpful. – David Ching Mar 12 '15 at 04:17
  • Total Commander worked. Thanks, pls edit your answer to spot easily the solution to others users. Thanks again. –  Mar 16 '15 at 21:36
  • I tried rmdir \\?\c:\mydir and all I get are errors saying the path is too long – James May 19 '16 at 00:52
0

You can use rimraf which is the unix command rm -rf for node.:

$ rimraf <name of dir to delete>

You can install rimraf using npm:

$ npm install -g rimraf
Pete
  • 205
  • 2
  • 8
0

Thanks to a newish open-source project released by Microsoft, you can easily delete paths that are too long using WinFile (which was introduced in WinXP). Sometimes you have to go "Back to the Future". This can delete paths too long on Microsoft networks share as well.

enter image description here

WinFile (compiled for Win10) available here https://github.com/Microsoft/winfile

To find many paths that are too long and automate a fix, I recommend Path Too Long Auto Fixer - a free demo is available.

Markus
  • 829
  • 7
  • 15