Nx — Smart Monorepos and Fast CI for JavaScript and Beyond
Nx is a build system and monorepo tool with first-class support for JavaScript, TypeScript, Go, Python, Java, and more. It offers computation caching, affected commands, task orchestration, and distributed execution — scaling from small repos to Google-sized codebases.
Installation agent prête
Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.
npx -y tokrepo@latest install dc0a4fee-37be-11f1-9bc6-00163e2b0d79 --target codexÀ exécuter après confirmation du plan en dry-run.
What it is
Nx is a build system and monorepo management tool with first-class support for JavaScript, TypeScript, Go, Python, Java, and more. It provides computation caching, affected-only commands, task orchestration with dependency graphs, and distributed execution across CI agents.
It targets development teams managing monorepos of any size, from small multi-package repositories to large enterprise codebases with hundreds of projects. Nx works as a standalone tool or integrates with existing package managers and build tools.
How it saves time or tokens
Nx caches task outputs (builds, tests, lints) locally and remotely. If code has not changed, Nx replays the cached result instead of re-running the task. The 'affected' command identifies which projects are impacted by a code change and only runs tasks for those projects. These two features together can reduce CI times by 50-90% on large monorepos.
How to use
- Install Nx:
npx create-nx-workspace@latestfor a new workspace, ornpx nx initto add Nx to an existing repo. - Define projects and their targets in
project.jsonorpackage.jsonfiles. - Run tasks with
npx nx run <project>:<target>or usenpx nx affected --target=testto only test changed projects.
Example
# Create a new Nx workspace
npx create-nx-workspace@latest myorg --preset=ts
# Run tests only for affected projects
npx nx affected --target=test --base=main
# Build all projects with caching
npx nx run-many --target=build --all
# Visualize the dependency graph
npx nx graph
Related on TokRepo
- Coding tools — Development tools and frameworks
- Automation tools — Build and workflow automation
Common pitfalls
- Nx cache invalidation depends on correct input/output configuration. Misconfigured task inputs cause stale cache hits that produce incorrect results.
- Adding Nx to an existing large repo requires upfront effort to define project boundaries and dependency relationships correctly.
- Remote caching (Nx Cloud) requires a connection to Nx's cloud service or a self-hosted cache server. Without remote caching, CI agents cannot share cache entries.
Questions fréquentes
No. Nx supports any language or tool that can be invoked from the command line. It has first-class plugins for JavaScript, TypeScript, React, Angular, Node, Go, Python, and Java. You can also define custom executors for any build tool.
Both provide task caching and affected-command detection. Nx has a larger plugin ecosystem, supports more languages natively, includes a project graph visualization tool, and offers distributed task execution. Turborepo is simpler to adopt for JavaScript-only monorepos.
Nx Cloud is Nx's optional remote caching and distributed execution service. It stores task cache entries in the cloud so CI agents and team members can share cached results. It has a free tier for small teams.
Yes. Running npx nx init in an existing workspace adds Nx on top of your current package manager. Nx reads your existing package.json scripts and enhances them with caching and dependency-aware orchestration.
Nx automatically analyzes imports, package.json dependencies, and configuration to build a project dependency graph. This graph determines build order, enables affected-only commands, and can be visualized in a browser with npx nx graph.
Sources citées (3)
- Nx GitHub Repository— Nx provides computation caching and monorepo management
- Nx Official Documentation— Nx documentation and guides
- Monorepo Tools Comparison— Monorepo tooling comparison
En lien sur TokRepo
Fil de discussion
Actifs similaires
Pants — Scalable Polyglot Build System for Monorepos
A fast, ergonomic build system that handles Python, Go, Java, Kotlin, Scala, Shell, Docker, and more in large monorepo codebases.
Turborepo — High-Performance JS/TS Monorepo Build System
Incremental build system for JavaScript and TypeScript monorepos by Vercel. Remote caching, parallel execution, and zero-config setup. Never rebuild unchanged packages. 28,000+ stars.
Changesets — Version and Changelog Management for Monorepos
Changesets is a tool for managing versioning and changelogs in JavaScript and TypeScript monorepos by letting developers declare their changes in small markdown files that get consumed at release time.
Turborepo — Rust Build System for JS Monorepos
Turborepo speeds JavaScript and TypeScript monorepos with task graphs, caching, and remote cache support. Use `turbo run` to standardize builds.