In a monorepo, you may have dozens or hundreds of projects to manage. Nx provides a task runner that lets you:Documentation 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.
- Run multiple targets for multiple projects in parallel
- Define task pipelines that execute in dependency order
- Run tasks only for projects affected by a change
- Speed up execution with caching
Define tasks
Nx tasks can come frompackage.json scripts, be inferred from tooling configuration files, or be defined explicitly in project.json. Nx merges all three sources for each project.
- project.json
- package.json
- Inferred by Nx plugins
Run tasks
Nx uses the syntaxnx <target> <project> or the long form nx run <project>:<target>.
Run a single task
Run tasks for multiple projects
Userun-many to run a target across all projects, or a filtered subset:
Run tasks on projects affected by a PR
Define a task pipeline
Many tasks must run in a specific order — for example, building dependencies before the application that uses them. Declare this innx.json using dependsOn:
^build syntax means “run build on all projects this project depends on first”. If you run nx build myreactapp and myreactapp depends on shared-ui and feat-products, Nx will build those two libraries before building the app.
You can define dependsOn globally in nx.json or per-project in project.json.
Reduce repetitive configuration
UsetargetDefaults in nx.json to set shared configuration that applies to all projects with a matching target name:
Run root-level tasks
For tasks that apply to the whole codebase rather than a single project, define them at the root level:- project.json
- package.json
