Nx
Basic Commands
Create a new NX workspace
npx create-nx-workspace@latest
Add NX to an existing project
npx add-nx-to-monorepo
Run the NX console
nx console
Run a specific target (e.g., build, serve, test) for a project
nx run <project>:<target>
Run a build for a project
nx build <project>
Serve a project
nx serve <project>
Workspace Management
Generate a new project
nx generate <schematic> <project_name>
Generate a new library
nx generate library <lib_name>
Generate a new application
nx generate app <app_name>
Run migrations
nx migrate latest
Format all workspace files
nx format
Lint all files in the workspace
nx lint
Testing & Affected Commands
Run tests for a project
nx test <project>
Run e2e tests for a project
nx e2e <project>
Run affected projects (based on changes)
nx affected --target=<target>
Show graph of affected projects
nx affected:graph
Caching & Dependency Graph
Clear the NX cache
nx reset
Show dependency graph for all projects
nx dep-graph
Show the dependency graph for affected projects
nx affected:dep-graph
Miscellaneous
Check NX version
nx --version
Last modified: 08 September 2024