LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

npm-prune

removes packages not in dependencies

TLDR

Remove extraneous packages
$ npm prune
copy
Remove devDependencies
$ npm prune --omit=dev
copy
Dry run to see what would be removed
$ npm prune --dry-run
copy
Output results as JSON
$ npm prune --json
copy
Prune a specific package
$ npm prune [package_name]
copy

SYNOPSIS

npm prune [[@scope/]pkg...] [options]

DESCRIPTION

npm prune removes extraneous packages not listed in the project's dependency tree. Extraneous packages are those installed but not referenced in package.json or any dependency's package.json.If --omit=dev is specified or the NODE_ENV environment variable is set to production, devDependencies are also removed. This is useful for preparing production deployments.When a package name is provided, only that package is pruned if it is extraneous.

PARAMETERS

--omit type

Dependency types to omit: dev, optional, or peer. Can be set multiple times.
--dry-run
Show what would be removed without making changes.
--json
Output results in JSON format.
--production
Deprecated alias for --omit=dev.

CAVEATS

Use --dry-run first to verify what will be removed. The --production flag is deprecated in favor of --omit=dev.

SEE ALSO

npm(1), npm-install(1), npm-ls(1), npm-dedupe(1)

Copied to clipboard
Kai