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:
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.
Written by Ciro Nunes
Related protips
3 Responses
Long Path Tool is Very Easy solution For this problem.
I would rather just empty the dependencies or devDependencies within package.json and then hit "npm prune". Voila.
eg.
"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'.
Solved.
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