Spent 3hrs the other day trying to figure out how to delete folder with node_modules in a windows box. I know you thinking, why not just google it! Trust me I did, but sometimes we look into wrong places for answers and that’s okay. I learned a thing or two in those 3 hours, they didn’t go to waste. Failing forward 🙂

Long story short here’s how you can resolve the issue: Use ROBOCOPY! Its so simple. I will not go over robocopy syntax in this blog (Let’s keep that for another day)

Steps

  1. Create an empty directory in your C:\ drive, for example mkdir emptyFolder
  2. Create another directory on your C:\ drive and copy(cut + paste rather) the folder failing to delete to that folder you just created. for example: mkdir myFolderToDelete
  3. Run the following command: robocopy <source> <destination> [command]

See below


robocopy C:\emptyFolder C:\myFolderToDelete /purge

There you have it, those node_modules or any other long path folder issues won’t bother you again 🙂

 

 

Advertisements