Last active
August 29, 2015 14:24
-
-
Save DamianMullins/20b15bff63e66d7fc46f to your computer and use it in GitHub Desktop.
Uninstall npm packages by scanning packages.json file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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