0

I managed to remove one Node folder using this solution (RMDIR /S), but for some reason with another one I got many "the file name is too long" error messages and the folder didn't get deleted, so the solution doesn't seem to work well.

Also tried this git bash solution to no avail.

I can't believe I'm struggling to perform such an elemental task. Do I actually have to do multiple command lines or install software to do this? Or is there some simple solution that very few people know about, if so what is it?

drake035
  • 1,249

2 Answers2

2

There is a way to delete folders with very long paths.

You didn't tell me where your Node folder is, so, I am going to have to answer you with an example. If you tell me the path your Node folder, however, I will update my answer with it. Now, imagine this path:

C:\a\folder\with\a\very\long\path

Pretend you cannot delete the very folder and anything below it because of a long path name error. You can instead open a Command Prompt and do this:

subst S: C:\a\folder\with\a
S:
rd very /s
c:
subst S: /d

The first command creates the alias "S:\" for "C:\a\folder\with\a". This way you whole path is now "S:\very\long\path" instead of "C:\a\folder\with\a\very\long\path". So, all you have to is to go to S: (second command) and delete everything in it. (Third command) Then, you can discard the alias. (Fourth and fifth commands.)

Bonus trick: Instead of running the third command, you open File Explorer and delete from there. Or do things that until this point were impossible to do.

1
npm install rimraf -g
rimraf node_modules

From: http://www.nikola-breznjak.com/blog/javascript/nodejs/how-to-delete-node_modules-folder-on-windows-machine/

drake035
  • 1,249