首页 Yarn

npm-prune

移除无关的包

概要

npm prune [[<@scope>/]<pkg>...] [--production] [--dry-run] [--json]

详情

此命令移除“无关”的包。如果提供了包名,那么只有名称匹配的那个包才会被移除。

无关的包指的是没有在父包的依赖关系列表中列出的包。

如果指定了 --production 参数,或者将 NODE_ENV 环境变量 设置为 production,这个命令将移除 devDependencies 配置信息中列出的包。设置 --no-production 将会取消 NODE_ENVproduction 的设置。

If the --dry-run flag is used then no changes will actually be made.

If the --json flag is used then the changes npm prune made (or would have made with --dry-run) are printed as a JSON object.

In normal operation with package-locks enabled, extraneous modules are pruned automatically when modules are installed and you'll only need this command with the --production flag.

If you've disabled package-locks then extraneous modules will not be removed and it's up to you to run npm prune from time-to-time to remove them.

请参阅

Last modified February 13, 2023           Found a typo? Send a pull request!

快速入门

命令行

npm 用法

配置 npm

故障排除