Windows Can't Delete Files

Source Path Too Long Error
Tagged: developmentThursday, November 30, 2017

Windows Can't Delete Long File/Path names as with /node_modules

I have ran into this problem an number of times where I can't delete a project that was using Node NPM because the dependency folders it creates is just too deep for windows to handle. And when you try to delete the /node_modules/ folder it gives you a Source Path Too Long error.

alt text

Run this Power Shell command to Recursive Delete the files

The best fix I found is to use this quick power shell script. So fire up Powershell (Press the windows key and search for it). And run the following command.

Be sure to adjust the Path, my example is a folder on my Desktop called Temp-Save that I need to delete all its contents

Get-ChildItem C:\Users\dpes\Desktop\Temp-Save -Recurse | Remove-Item

Your results should look something like this where you have to confirm you really want to delete everything.

alt text