Last Updated: August 23, 2016
· cironunes

Delete files/folders with long paths on Windows

When you use NPM in your projects and install some modules, their paths too long. So if you try to delete them, you'll see the following error message:

The source file name(s) are larger than is supported by the file system.

Th reason why, is that the Windows API, the maximum length for a path is defined as 260 character.

To solve that you can use robocopy:

$ mkdir [empty_tmp_dir]
$ robocopy [dir_to_delete] [empty_tmp_dir] /s /mir
$ rmdir [dir_to_delete] [empty_tmp_dir]
  • In the first line we create an empty temporary folder.
  • In the second we use robocopy to do the trick for us with the help of the temp folder which we created in the first line.
  • In the third line we remove both folders.

3 Responses
Add your response

Long Path Tool is Very Easy solution For this problem.

over 1 year ago ·

I would rather just empty the dependencies or devDependencies within package.json and then hit "npm prune". Voila.


"devDependencies": {

Now, hit npm prune - and it will remove all npm_modules. Its also help if you wish to remove only certain modules. In that case - you just want to remove that particular module name from your dependencies from package.json and then again 'npm prune'.


over 1 year ago ·

i was searching dwindows path too long solution, and i found this
article, nice, but i got the solution using 'Long Path Tool" your all information helped me. thanks

over 1 year ago ·