pnpm run: Usage, Options & Common Errors
Run scripts in one package or across the workspace.
pnpm run executes a named script from package.json. Add -r to run it across every workspace package, or --filter to target a subset.
What it does
Runs the named script with node_modules/.bin on PATH. -r (recursive) runs it in every workspace package that defines it, in topological order; --filter narrows to matching packages. Args after the script are passed through.
Common usage
pnpm run build # run build in this package
pnpm build # "run" is optional for non-builtins
pnpm -r run test # run test in every workspace
pnpm --filter @acme/web run devCommon CI error: recursive run fails on one package
pnpm -r run build aborts because one workspace package fails to build. By default pnpm stops on the first failure. Use --filter to isolate the failing package, or pass --no-bail to keep going and collect all failures in one CI run.
pnpm -r --no-bail run build # don't stop at the first failureUsing this in CI
Node tooling on a runner differs from your machine in three ways that matter: CI=true is set, there is no TTY, and the Node major may not be the one you develop on.
- Pin the Node major with
setup-nodeand inengines. Native modules resolve different prebuilt binaries per major. CI=truechanges behaviour in several tools, most often by promoting warnings to errors or disabling interactive prompts.- Commands that expect a TTY will hang. Pass the non-interactive or
--yesflag explicitly. - Use
npm execornode_modules/.binrather than assuming a globally installed binary is on PATH.