Nx is a smart monorepo build system that amplifies developer productivity through intelligent caching, distributed task execution, and code generation. Built for managing large-scale codebases with multiple applications and libraries, Nx provides robust tooling for React, Angular, Node.js, and other frameworks. What sets Nx apart is its computation caching and affected command analysis — features that drastically reduce build times by only rebuilding what changed, making it indispensable for teams working with interconnected projects where one change shouldn't trigger a full workspace rebuild.
What This Cheat Sheet Covers
This topic spans 12 focused tables and 84 indexed concepts, 69 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Core CLI Commands
These are the commands you'll type every day. The standouts are nx affected and nx run-many — they're how you run tasks across a sprawling workspace without touching projects that didn't change — while nx graph, nx reset, and nx migrate cover visualizing dependencies, clearing a misbehaving cache, and staying current with breaking changes.
| Command | Example | Description | |
|---|---|---|---|
nx run my-app:buildnx run my-lib:test | • Executes a specific target for a project • targets include build, test, serve, lint, and custom executors defined in project configuration | ||
nx affected -t build testnx affected -t lint --base=main | • Runs tasks only on projects affected by code changes • compares current branch against a base to determine dependency impact and minimize CI time | ||
nx run-many -t build --allnx run-many -t test --projects=tag:api | • Executes tasks across multiple projects in parallel • supports filtering by tags, project names, or glob patterns with configurable parallelism limits | ||
nx graphnx graph --affected | Opens interactive dependency graph visualization showing relationships between projects, tasks, and affected scope after code changes. | ||
nx migrate latestnx migrate --run-migrations | Generates migration plan for updating Nx and workspace dependencies, then applies automated code transformations to adapt to breaking changes. | ||
nx resetnx reset --onlyCloud | • Clears local task cache and stops daemon process • use when debugging cache issues or after configuration changes that affect hashing | ||
nx show project my-appnx show projects --affected | • Displays detailed project configuration, tasks, dependencies, and metadata • useful for debugging and understanding project structure | ||
nx watch --projects=my-app -- echo "Changed!"nx watch --all -- nx test | • Monitors file changes and triggers custom commands on detection • enables continuous task execution during development workflows | ||
nx format:writenx format:check --base=main | • Formats code using Prettier • format:write applies changes while format:check validates without modifying files for CI validation | ||
nx import https://github.com/org/reponx import ../existing-repo --ref=main | • Imports external repositories into workspace while preserving git history • useful for consolidating multiple repos into a single monorepo |