← 返回命令列表

Linux command

npm-prune 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Remove extraneous packages

npm prune

Remove devDependencies

npm prune --omit=dev

Dry run to see what would be removed

npm prune --dry-run

Output results as JSON

npm prune --json

Prune a specific package

npm prune [package_name]

说明

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.

参数

--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.

FAQ

What is the npm-prune command used for?

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.

How do I run a basic npm-prune example?

Run `npm prune` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --omit _type_ do in npm-prune?

Dependency types to omit: dev, optional, or peer. Can be set multiple times.