pnpm remove

别名:rm、uninstall、un

从 node_modules 和 package.json 中删除软件包。

Since v11.28.0, pnpm remove runs the project's own preuninstall, uninstall, and postuninstall scripts. See Uninstall scripts.

配置项#

--recursive, -r#

当在 工作空间 中使用时,从每个工作空间包中除去一个(或多个)依赖关系 。

当不在工作空间内使用时,将在子目录中找到的每个包中删除一个(或多个)依赖。

Since v11.28.0, the command fails before any package.json is modified if a requested dependency is absent from every selected project. The check respects --save-prod, --save-dev, and --save-optional.

--global, -g#

删除全局软件包。

--save-dev, -D#

仅从 devDependencies 中删除依赖项。

--save-optional, -O#

仅从 optionalDependencies 中删除依赖项。

--save-prod, -P#

仅从 dependencies 中删除相关依赖项。

--unsafe-perm#

Added in: v11.26.0

Accepted for compatibility with pnpm install; see unsafePerm.

Supply-chain policy flags#

Added in: v11.26.0

pnpm remove accepts the same policy overrides as pnpm install and pnpm add: --trust-lockfile, --no-trust-lockfile, --trust-policy, --trust-policy-exclude, and --trust-policy-ignore-after.

Removing a package rewrites the lockfile, so pnpm remove verifies the whole lockfile against the active policies the way pnpm install does, not only the entries of the package being removed. --trust-lockfile skips that pass entirely.

--filter <package_selector>#

阅读更多有关过滤的内容。