Nx Commands Reference
Quick reference for Nx monorepo commands used in the EBRAINS UI Ecosystem.
Generate Commands
Generate React Application
Common options:
--directory- Where to create the app--style- CSS, scss, styled-components, emotion--bundler- vite (recommended), webpack--routing- true/false (include React Router)--unitTestRunner- vitest, jest, none
Generate React Library
Generate React Component
Generate Hook
Development Commands
Serve Application
Common serve ports:
- Applications: 4200, 4300, 4400
- Handbook (Hugo): 1313
Build Application
Output location:
- Default:
dist/apps/<app-name>/
Test Application
Lint Application
Monorepo Commands
Run Task for Multiple Projects
Affected Commands
Project Graph
Workspace Commands
List Projects
Reset Nx Cache
Workspace Configuration
Hugo (Handbook) Commands
The EBRAINS Handbook uses Hugo, accessed through Nx:
Handbook URL: http://localhost:1313
Common Workflows
Create New React App
Create Shared Library
Run Quality Checks
Check What Changed
Configuration Files
Project Configuration
Location: apps/<app-name>/project.json or packages/<lib-name>/project.json
Workspace Configuration
Location: nx.json
Package Management
Install Dependencies
Update Dependencies
Debugging
Verbose Output
Skip Cache
Environment Variables
Common Options
| Option | Description | Example |
|---|---|---|
--help | Show help | nx serve --help |
--version | Show Nx version | nx --version |
--verbose | Verbose output | nx build my-app --verbose |
--skip-nx-cache | Skip Nx cache | nx build my-app --skip-nx-cache |
--parallel | Run tasks in parallel | nx run-many --target=test --all --parallel=3 |
--output-style | Output format | nx build --output-style=stream |
Troubleshooting
Port Already in Use
Command Not Found: nx
Module Not Found
Cache Issues
Build Fails After Dependency Update
Best Practices
Do
- Use
npx nxinstead of globalnxfor consistency - Run
nx affectedfor efficient CI/CD - Use Nx cache for faster builds
- Generate projects with Nx generators
- Keep dependencies up to date
- Use
--dry-runto preview changes - Review project.json for custom targets
Don’t
- Don’t modify dist/ folder manually
- Don’t skip migrations after updates
- Don’t use
nx resetas first debugging step - Don’t ignore linting errors
- Don’t create projects manually (use generators)
- Don’t commit node_modules/
Quick Reference Table
| Task | Command |
|---|---|
| Generate React app | npx nx generate @nx/react:application my-app |
| Serve app | nx serve my-app |
| Build app | nx build my-app |
| Test app | nx test my-app |
| Lint app | nx lint my-app |
| View graph | nx graph |
| Run for all | nx run-many --target=build --all |
| Run affected | nx affected --target=test |
| Reset cache | nx reset |
| List projects | nx list |
Related Documentation
- Build Your First App Tutorial - Complete guide
- npm Commands Reference - Package management
- Nx Documentation - Official Nx docs
- Nx React Plugin - React-specific commands