跳到主内容
Version: 6.x

pnpm CLI

与 npm 的差别#

与 npm 不同的是,pnpm 会校验所有的参数。 比如,pnpm install --foo 会执行失败,因为 --foo 不是 pnpm install 的有效参数。

但是,某些依赖关系可能使用 npm_config_ 环境变量,其中 从 CLI 选项中填充。 在这种情况下,你有以下选择:

  1. 设置明确的环境变量:npm_config_foo=true pnpm install
  2. force the unknown option with --config.: pnpm install --config.foo

Options#

-C <path>, --dir <path>#

Run as if pnpm was started in <path> instead of the current working directory.

-w, --workspace-root#

Added in: v5.6.0

Run as if pnpm was started in the root of the workspace instead of the current working directory.

Commands#

For more information, see the documentation for individual CLI commands. Here is a list of handy npm equivalents to get you started:

npm commandpnpm equivalent
npm installpnpm install
npm i <pkg>[pnpm add <pkg>]
npm run <cmd>[pnpm <cmd>]