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). Parallel output stays live through short buffered sections, while an optional -n, --node-env value explicitly controls NODE_ENV for the matched child scripts.

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).
  • Set NODE_ENV for child scripts without relying on platform-specific shell syntax or Nova guessing from script names.
  • Keep concurrent output readable with script labels, section frames, preserved child colors, and one final failure summary.

Use Cases

  • Build pipelines — Run build:* scripts sequentially with an explicit production environment so each step shares the same intent.
  • Development mode — Run dev:* scripts in parallel with an explicit development environment 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.
-n, --node-env <environment>Set child NODE_ENV to development, production, or test. Omit it to preserve the caller value.

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 retains its own ANSI colors, receives a [script-name] prefix, and appears inside ┌─ script-name ── and └─ script-name ── frames. The time-windowed queue keeps output live while grouping contiguous lines; use --buffer to adjust its flush interval (default: 500 ms).

When concurrent scripts fail, Nova lets every script finish and then prints one compact summary containing each failed script and its exit code or startup error.

Pressing Ctrl + C in parallel mode stops every active child script, waits for shutdown to finish, and exits cleanly without treating expected signal exits as failures.

--node-env is explicit by design. Nova does not infer an environment from names such as build:* or dev:*. The selected value applies only to the child scripts; Nova does not mutate the parent process. If the option is omitted, the children inherit the caller's existing NODE_ENV unchanged.

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 200—Run concurrently with 200 ms log flush interval.
nova utility run-scripts "build:*" --sequential --node-env production—Run sequentially with an explicit child NODE_ENV.

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.
  • Unsupported Node environment — Use development, production, or test with --node-env, or omit the option to inherit the caller's value.
  • 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. Review the final Failed scripts summary for every failed script and its exit code or startup error.