pnpm exec

在项目范围内执行 shell 命令。

node_modules/.bin 被添加到 PATH,因此 pnpm exec 允许执行依赖项的命令。

示例#

If you have Jest as a dependency of your project, there is no need to install Jest globally. Run it with pnpm exec:

pnpm exec jest

The exec part is actually optional when the command is not in conflict with a builtin pnpm command, so you may also run:

pnpm jest

配置项#

exec 命令的任何选项都应该在 exec 关键字之前列出。在 exec 关键字之后列出的选项都将被传递给被执行的命令。

好的做法。 pnpm 将以递归的方式运行:

pnpm -r exec jest

糟糕的做法,pnpm 将不会以递归方式运行,但 jest 将使用 -r 选项执行。

pnpm exec jest -r

--recursive, -r#

在工作区的每个项目中执行 shell 命令。

当前软件包的名称可通过环境变量 PNPM_PACKAGE_NAME 获取。

示例#

为所有的软件包清理 node_modules 安装。

pnpm -r exec rm -rf node_modules

查看所有包的包信息。这应该与 --shell-mode(或 -c)选项一起使用,以使环境变量起作用。

pnpm -rc exec pnpm view \$PNPM_PACKAGE_NAME

--no-reporter-hide-prefix#

并行运行命令时不隐藏前缀。

--resume-from <package_name>#

Resume execution at a particular project. pnpm skips the projects a matching record of the previous recursive exec says already passed. Without such a record, it omits the named project's transitive dependencies, but still runs the named project, its dependents, and unrelated projects in the selected graph. See Workspace task orchestration.

--parallel#

完全忽略并发和拓扑排序,在所有匹配的包中立即运行给定的脚本。对于许多包中长时间运行的进程,这是首选标志,例如漫长的构建进程。

--shell-mode, -c#

在 shell 中运行该命令。在 UNIX 上使用 /bin/sh,在 Windows 上使用 \cmd.exe。

--report-summary#

在运行命令文档中阅读有关此选项的信息

--filter <package_selector>#

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