In a monorepo, tasks rarely run in isolation. BuildingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt
Use this file to discover all available pages before exploring further.
myapp requires building shared-ui and feat-products first. Nx manages these relationships through a task pipeline — a set of rules that determine execution order and parallelism.
Why pipelines matter
Without a task pipeline, you have two bad options:- Run tasks serially in a manually maintained order — slow and brittle as the repo grows.
- Run all tasks in parallel — broken, because some tasks depend on the outputs of others.
shared-ui:build and feat-products:build are sequenced correctly, and anything that doesn’t share a dependency edge runs in parallel.
Configuring task dependencies
Task dependencies are declared with thedependsOn property. You can set this globally in nx.json under targetDefaults, or locally in a project’s project.json or package.json.
Global defaults in nx.json
nx.json
nx test myproj causes Nx to:
- Run
myproj:buildfirst (becausetestdepends onbuildof the same project) - Run
buildfor all ofmyproj’s dependencies first (becausebuilddepends on^build— the^means “dependencies in the project graph”) - Run
myproj:prebuildbeforemyproj:build(same-project dependency without^)
Per-project configuration
Project-level configuration overrides global defaults for that project only:apps/myapp/project.json
The dependsOn syntax
`"^build"` — dependency project tasks
`"^build"` — dependency project tasks
The
^ prefix means “run this target for all projects that this project depends on in the project graph.” This is the most common pattern for build tasks, ensuring that library builds complete before app builds start.`"prebuild"` — same-project task
`"prebuild"` — same-project task
Without a
^, the dependency refers to a target on the same project. This lets you chain targets within a single project.`{ "projects": "...", "target": "..." }` — explicit project targets
`{ "projects": "...", "target": "..." }` — explicit project targets
You can also declare dependencies on specific named projects:
Parallelism
Nx runs as many tasks in parallel as the dependency constraints allow. The default parallelism limit is 3 concurrent tasks. You can override this with--parallel:
Tasks that share a dependency edge always run sequentially in the correct order. Only tasks with no dependency relationship between them run in parallel.
Example: parallel vs. sequential
Given three projects whereapp1 and app2 both depend on lib:
nx.json
nx run-many -t build produces this execution order:
lib:build completes. Nx does not wait for one app to finish before starting the other.
Mixing targets in one run
Task graphs can contain different targets running simultaneously. For instance, while Nx is buildingapp2, it can be testing app1 at the same time — as long as neither task depends on the other.
Scope of configuration
| Location | Scope | Override priority |
|---|---|---|
nx.json targetDefaults | All projects | Lowest |
project.json / package.json per-project | Single project | Highest |
targetDefaults.
