Aliases: run-script
Runs a defined package script.
pnpm run [[-r] [--no-bail] [--no-sort] [--workspace-concurrency=<number>]]
<command> [-- <args>...]
Run the watch
task:
pnpm run watch
Same thing without the run
keyword will work as well:
pnpm watch
In addition to the shell’s pre-existing PATH
, pnpm run
adds node_modules/.bin
to the PATH
provided to scripts
. As of v3.5, when executed inside a workspace,
<workspace root>/node_modules/.bin
is also added to the PATH
, so if a tool
is installed in the workspace root, it may be called in any workspace package's scripts
.
Added in: v5.10.0
The shell to use for scripts run with the pnpm run
command.
Probably the most useful example of usage is forcing Git's bash shell on Windows:
pnpm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe
Added in: v5.8.0
When true
, pnpm will use a JavaScript implementation of a bash-like shell to execute scripts.
This option simplifies cross-platform scripting. For instance, by default the next script will fail on Windows:
{
"scripts": {
"test": "NODE_ENV=test node test.js"
}
But if the shell-emulator
setting is set to true
, it will work on all platforms.
This runs an arbitrary command from each package's "scripts" object. If a package doesn't have the command, it is skipped. If none of the packages have the command, the command fails.
Added in: v4.5.0
You can use the --if-present
flag to avoid exiting with a non-zero exit code
when the script is undefined. This lets you run potentially undefined scripts
without breaking the execution chain.
Added in: v5.1.0
Completely disregard concurrency and topological sorting, running a given script immediately in all matching packages with prefixed streaming output. This is the preferred flag for long-running processes such as watch run over many packages.
pnpm run --parallel watch
Added in: v5.1.0
Stream output from child processes immediately, prefixed with the originating package directory. This allows output from different packages to be interleaved.