Skip to content

Instantly share code, notes, and snippets.

@SynCap
Last active May 3, 2024 21:37
Show Gist options
  • Save SynCap/3dded8070dce3013fdc3fd4f95383651 to your computer and use it in GitHub Desktop.
Save SynCap/3dded8070dce3013fdc3fd4f95383651 to your computer and use it in GitHub Desktop.
Remove `node_modules` folders in Windows in all subfolders recursively with PowerShell to avoid exceeding path max_length
<#
Note: Eliminate `-WhatIf` parameter to get action be actually done
Note: PS with version prior to 4.0 can't delete non-empty folders
#>
Get-ChildItem -Path "." -Include "node_modules" -Recurse -Directory | Remove-Item -Recurse -Force -WhatIf
@dcarrascosa
Copy link

This command don't perform a delete of all node_modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment