Skip to content

Instantly share code, notes, and snippets.

@ryanmoralesaz
Created October 24, 2025 04:09
Show Gist options
  • Select an option

  • Save ryanmoralesaz/642c7f385a01ee19adb41e8dbdc7933c to your computer and use it in GitHub Desktop.

Select an option

Save ryanmoralesaz/642c7f385a01ee19adb41e8dbdc7933c to your computer and use it in GitHub Desktop.
Clean node modules in current folder Windows Powershell $PROFILE
function cleanmodules {
Write-Host "Searching for node_modules folders..." -ForegroundColor Yellow
$folders = Get-ChildItem -Path . -Filter "node_modules" -Recurse -Directory
if ($folders.Count -eq 0) {
Write-Host "No node_modules folders found." -ForegroundColor Green
return
}
Write-Host "Found $($folders.Count) node_modules folder(s). Deleting..." -ForegroundColor Red
$folders | ForEach-Object {
Write-Host " Removing: $($_.FullName)" -ForegroundColor Red
Remove-Item $_.FullName -Recurse -Force
}
Write-Host "Done!" -ForegroundColor Green
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment