Skip to content

rush run

Terminal window
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.


FlagDefaultDescription
--no-pre-post-scriptsfalseSkip pre<script> and post<script> hooks; run only the named script

Run a build script (with hooks):

Terminal window
rush run build
# runs: prebuild → build → postbuild

Run without hooks:

Terminal window
rush run build --no-pre-post-scripts
# runs: build only

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:

Terminal window
rush run test -- --watch --coverage

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...

Every script runs via /bin/sh -c with:

  • node_modules/.bin prepended to $PATH — local executables (like tsc, vite) work without a full path
  • npm_package_name — value of name in package.json
  • npm_package_version — value of version in package.json
  • npm_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.


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.