Skip to content

Instantly share code, notes, and snippets.

@DamianMullins
Last active August 29, 2015 14:24
Show Gist options
  • Save DamianMullins/20b15bff63e66d7fc46f to your computer and use it in GitHub Desktop.
Save DamianMullins/20b15bff63e66d7fc46f to your computer and use it in GitHub Desktop.
Uninstall npm packages by scanning packages.json file.
Function Uninstall-NpmPackages {
Param (
# Optional path to package.json
[String]$pathToPackage = $(Resolve-Path "package.json")
)
# Read the json content
$json = (Get-Content $pathToPackage) -join "`n" | ConvertFrom-Json
# Loop over each package in devDependencies
ForEach ($dep in $json.devDependencies.psobject.properties.name) {
# Uninstall the package
iex "npm uninstall $dep"
#iex "echo $dep"
}
}
#Uninstall-NpmPackages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment