For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/guides/troubleshooting/cli.md.
  • 简体中文
  • 命令行问题

    使用 pnpm 时无法正确传递命令行参数?

    在使用 pnpm 调用 package.json 中的命令时,需要注意参数传递的方式:

    • 如果需要传递参数至 pnpm,需要将参数放到命令前。

    例如使用 pnpm --filter 参数执行 prepare 命令:

    pnpm run --filter "./packages/**" prepare
    • 如果需要传递参数至命令,需要将参数放到命令后。

    例如,在如下 package.json 配置中:

    {
      "scripts": {
        "command": "modern command"
      }
    }

    执行 command 命令时携带参数方式为:

    pnpm run command --options
    Tip

    Modern.js 要求 Node.js >= 20.19.5,而 pnpm v6 不支持 Node.js 20,因此请使用 pnpm v7 或更高版本。