rush run
rush run <script> [args...] [flags]Executes a script defined in the scripts field of package.json. Rush automatically runs pre<script> and post<script> hooks when they exist.
| Flag | Default | Description |
|---|---|---|
--no-pre-post-scripts | false | Skip pre<script> and post<script> hooks; run only the named script |
Examples
Section titled “Examples”Run a build script (with hooks):
rush run build# runs: prebuild → build → postbuildRun without hooks:
rush run build --no-pre-post-scripts# runs: build onlyrush run vs rush exec
Section titled “rush run vs rush exec”Use rush run for scripts defined in package.json. Use rush exec to invoke a node_modules/.bin binary directly without a script definition.
Pass arguments to the script:
rush run test -- --watch --coverageLifecycle hooks
Section titled “Lifecycle hooks”Given a package.json like:
{ "scripts": { "prebuild": "rm -rf dist", "build": "tsc", "postbuild": "cp -r assets dist/" }}Running rush run build executes all three in order. If any hook exits with a non-zero status, execution stops immediately.
Running prebuild...Running build...Running postbuild...Environment
Section titled “Environment”Every script runs via /bin/sh -c with:
node_modules/.binprepended to$PATH— local executables (liketsc,vite) work without a full pathnpm_package_name— value ofnameinpackage.jsonnpm_package_version— value ofversioninpackage.jsonnpm_lifecycle_event— name of the currently running script ("prebuild","build","postbuild")
This matches npm’s environment, so scripts written for npm work with Rush without modification.
Exit codes
Section titled “Exit codes”If the script (or any hook) exits with a non-zero code, rush run exits with the same code. This makes it safe to use in CI pipelines.