Movatterモバイル変換


[0]ホーム

URL:


跳至主要內容
此為 pnpm9.x 版的文件,現已不再積極維護。
關於最新的文件,請參閱最新發行版本(10.x)。
版本:9.x

pnpm exec

在專案的範圍中執行 Shell 命令。

node_modules/.bin is added to thePATH, sopnpm exec allows executing commands of dependencies.

Examples

If you have Jest as a dependency of your project, there is no need to install Jest globally, just run it withpnpm exec:

pnpm exec jest

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

pnpm jest

Options

Any options for theexec command should be listed before theexec keyword.Options listed after theexec keyword are passed to the executed command.

正確範例, pnpm 將遞迴地執行:

pnpm -r exec jest

Bad, pnpm will not run recursively butjest will be executed with the-r option:

pnpm exec jest -r

--recursive, -r

在 workspace 的每個專案中都執行 shell 命令。

The name of the current package is available through the environment variablePNPM_PACKAGE_NAME.

Examples

Prunenode_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

--no-reporter-hide-prefix

Do not hide prefix when running commands in parallel.

--resume-from <package_name>

Resume execution from a particular project. This can be useful if you are working with a large workspace and you want to restart a build at a particular project without running through all of the projects that precede it in the build order.

--parallel

Completely disregard concurrency and topological sorting, running a given scriptimmediately in all matching packages. This is thepreferred flag for long-running processes over many packages, for instance, alengthy build process.

--shell-mode, -c

Runs the command inside of a shell. Uses/bin/sh on UNIX and\cmd.exe on Windows.

--report-summary

Read about this option in the run command docs

--filter <package_selector>

Read more about filtering.


[8]ページ先頭

©2009-2025 Movatter.jp