pnpm exec
在项目范围内执行 shell 命令。
node_modules/.bin
is added to the PATH
, so pnpm exec
allows executing commands of dependencies.
示例
If you have Jest as a dependency of your project, there is no need to install Jest globally, just 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 just run:
pnpm jest
配置项
Any options for the exec
command should be listed before the exec
keyword.
Options listed after the exec
keyword are passed to the executed command.
好的做法。 pnpm 将以递归的方式运行。
pnpm -r exec jest
Bad, pnpm will not run recursively but jest
will be executed with the -r
option:
pnpm exec jest -r
--recursive, -r
在工作区的每个项目中执行 shell 命令。
The name of the current package is available through the environment variable
PNPM_PACKAGE_NAME
.
示例
Prune node_modules
installations for all packages:
pnpm -r exec rm -rf node_modules
查看所有包的包信息。 This should be used with the --shell-mode
(or -c
) option for the environment variable to work.
pnpm -rc exec pnpm view \$PNPM_PACKAGE_NAME
--resume-from <package_name>
从特定项目恢复执行。 如果您正在使用大型工作区,并且想要在不运行先前项目的情况下从特定项目重新启动构建,那么这可能非常有用。
--parallel
完全忽略并发和拓扑排序,在所有匹配的包中立即运行给定的脚本
并输出前缀流。 这是个推荐的标志,用于在许多 packages
上长时间运行的进程,例如冗长的构建进程。
--shell-mode, -c
在 shell 中运行该命令。 Uses /bin/sh
on UNIX and \cmd.exe
on Windows.
--report-summary
Read about this option in the run command docs