pnpm pm

pnpm pm <command> 语法总是运行内置的 pnpm 命令,绕过 package.json 中任何同名的脚本。

一些内置命令可以被脚本覆盖。例如,如果你的项目在 package.json 中定义了一个 "clean" 脚本,那么 pnpm clean 将运行该脚本而不是内置的 pnpm clean。使用 pnpm pm clean 会强制运行内置命令。

These commands run a same-named script when one exists:

An alias looks up its own script name, so pnpm rb runs an rb script, not a rebuild script.

Inside a workspace, running one of these commands from a subdirectory fails with ERR_PNPM_SCRIPT_OVERRIDE_IN_WORKSPACE_ROOT when the root package.json has a script of that name. Run pnpm pm <command> to use the built-in command, or pnpm run <command> from the workspace root to run the script.

示例#

package.json
{
  "scripts": {
    "clean": "rm -rf dist"
  }
}
# Runs the "clean" script from package.json
pnpm clean
# or explicitly:
pnpm run clean

# Runs the built-in pnpm clean command
pnpm pm clean