API Reference

Nx

Smart monorepo toolkit with computation caching, project graph analysis, and generic generators and executors.

Official Documentation ↗
CompatibilityThis documentation covers version v24.0.4. Check the official docs for the latest API surface.

Installation

npmnpm install --save-dev nx
pnpmpnpm add -D nx

Methods

Overview

Nx is a monorepo toolkit that caches computations, analyzes a project graph, and offers generators and executors for consistent scaffolding. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.

Core APIs

  • nx run — Executes a single target for one project with caching and optional remote cache.
  • nx affected — Runs a target only for projects affected by changes between two git refs.
  • nx generate — Scaffolds code or configuration through a generator in a consistent structure.

Example

nx run my-app:build --configuration=production

Notes

The project graph is inferred from configuration and imports, so dynamic require patterns can hide dependencies and cause incorrect affected results.

Verification

Change one leaf package and run nx affected for its dependents, confirming only truly dependent projects rebuild.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://nx.dev/reference/commands · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:17.274Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://nx.dev/reference/commands · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:17.274Z.

  • Note: your shell may require you to escape the * like this: * : Terminal window nx run-many -t test –projects= * -app –exclude excluded-app Test all projects with tags starting with api- . (https://nx.dev/reference/commands)
  • Managers CTO & VPs Eng Security Products Nx Nx Cloud Nx Labs Status Resources Tutorials Webinars Customers Case Studies Monorepo 101 Metaharness 101 Company About us Careers Contact us © 2026 Nrwl. (https://nx.dev/reference/commands)

FAQ

How does Nx decide what is affected?
Nx builds a project graph from imports and workspace config; affected compares file changes between --base and --head to that graph.
Can Nx run without its plugins?
Yes. Nx can orchestrate any package scripts as targets, and plugins add generators, executors, and graph inference on top.
How do I enable distributed caching?
Use Nx Cloud by running nx connect, which enables remote caching and distributed task execution across agents.