Skip to content

Instantly share code, notes, and snippets.

@DamianMullins
Last active August 29, 2015 14:24
Show Gist options
  • Save DamianMullins/428b9f8b7bfee7e05730 to your computer and use it in GitHub Desktop.
Save DamianMullins/428b9f8b7bfee7e05730 to your computer and use it in GitHub Desktop.
Uninstall npm packages by scanning directories inside node_modules
Function Uninstall-NpmPackagesInDirectory {
Param (
# Optional path to node_modules directory
[String]$pathToNodeModules = (Get-Item -Path ".\node_modules").FullName
)
# Loop over each folder in the directory
ForEach ($dep in Get-ChildItem -Path $pathToNodeModules | ? { $_.FullName -notmatch ".bin" }) {
# Uninstall the package
iex "npm uninstall $dep"
#iex "echo $dep"
}
}
#Uninstall-NpmPackagesInDirectory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment