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,097
  • 7
  • 19
  • 33

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.

  • Thank you but this is not what I call simple. I'm looking for something a lot more straightforward, because it's such a straightforward thing to delete a folder! – drake035 Mar 05 '17 at 21:24
  • @drake035 Thanks to a bug that Microsoft is refusing to resolve, deleting a folder is NOT a straightforward task. Here, we give you practical answers. We can't do magic for you. –  Mar 06 '17 at 07:11
  • Sorry Fleet Command I truly appreciate the time you spent on your answer but it's too complicated. I found something way simpler: "npm install rimraf -g" followed by "rimraf node_modules" (http://www.nikola-breznjak.com/blog/javascript/nodejs/how-to-delete-node_modules-folder-on-windows-machine/) – drake035 Mar 07 '17 at 09:37
  • No worries. I got ten points out of it and you have a way of deleting folders with long paths that aren't Node.js-related. –  Mar 07 '17 at 10:16
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,097
  • 7
  • 19
  • 33