Skip to main content

Run Scripts

Run package.json scripts by pattern in sequential or parallel mode with no extra dependencies.

Summary

The run-scripts command reads the scripts field from the nearest package.json, matches script names by a prefix pattern (e.g., build:*), and runs them either sequentially (stopping on first failure) or concurrently (reporting all failures).

Why Use This Command?

  • Run related scripts (e.g., build:clean, build:transpile, build:fix-alias) in a single command with no extra dependencies.
  • Choose between sequential execution (for ordered pipelines) and parallel execution (for independent tasks).
  • Get clear exit codes and error messages when a script fails.

Use Cases

  • Build pipelines — Run build:* scripts sequentially so each step depends on the previous one.
  • Development mode — Run dev:* scripts in parallel to start watchers, dev servers, and other tools concurrently.
  • CI/CD checks — Run check:* scripts sequentially or in parallel depending on whether order matters.
  • Cleanup tasks — Run clean:* scripts in parallel since cleanup operations are independent.

Requirements

  • Node.js runtime — Use any Node.js LTS release with either the installed nova CLI or npx.
  • package.json — A valid package.json with a scripts field must exist in the current working directory.

Usage

You can run this command in two ways:

Options

FlagDescription
-s, --sequentialRun matched scripts one at a time, stopping on failure.
-p, --parallelRun matched scripts concurrently.
-b, --buffer <ms>Flush interval in milliseconds for parallel log grouping. Defaults to 500.

Exactly one of --sequential or --parallel is required. The <pattern> argument supports a trailing wildcard (e.g., build:*) to match all scripts sharing a common prefix, or an exact script name.

In parallel mode, each script's output is prefixed with [script-name] and grouped using a time-windowed log queue. Use --buffer to adjust the flush interval (default: 500 ms).

Examples

Migration from npm-run-all

For users migrating from the npm-run-all workflow, Nova provides equivalent flags under nova utility run-scripts:

CommandEquivalentWhat It Does
nova utility run-scripts 'build:*' --sequentialnpm-run-all --sequential build:*Run matched scripts one at a time.
nova utility run-scripts 'dev:*' --parallelnpm-run-all --parallel dev:*Run matched scripts concurrently.
nova utility run-scripts 'dev:*' --parallel --buffer 200Run concurrently with 200 ms log flush interval.

After updating your scripts in package.json, npm-run-all can be removed from devDependencies.

Troubleshooting

  • No "package.json" found — Confirm a package.json exists in the current working directory before running the command.
  • No scripts matched — Verify that your pattern matches at least one key in the scripts field. A trailing * matches by prefix (e.g., build:* matches build:clean, build:transpile).
  • Both modes specified — Use either --sequential or --parallel, not both. The command will exit with an error if both are provided.
  • Script fails in sequential mode — Execution stops at the first failure. Fix the failing script and re-run.
  • Script fails in parallel mode — All scripts run to completion. Check the output for which scripts failed.