nx-workspace
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNx Workspace Management
Nx工作区管理
Quick Start
快速开始
Exploring workspace: and
Running tasks: (e.g., )
Affected analysis: or
nx show projectsnx show project <name> --jsonRunning tasks:
nx <target> <project>nx build my-appAffected analysis:
nx show projects --affectednx affected -t <target>Note: Prefix commands with/npx/pnpxif nx isn't installed globally.yarn
探索工作区: 和
运行任务:(例如:)
受影响项目分析: 或
nx show projectsnx show project <name> --json运行任务:
nx <target> <project>nx build my-app受影响项目分析:
nx show projects --affectednx affected -t <target>注意:如果未全局安装nx,请在命令前添加/npx/pnpx前缀。yarn
Core Commands
核心命令
List and Explore Projects
列出并探索项目
bash
undefinedbash
undefinedList all projects
列出所有项目
nx show projects
nx show projects
Filter by type, pattern, or target
按类型、匹配模式或目标过滤
nx show projects --type app
nx show projects --projects "apps/*"
nx show projects --withTarget build
nx show projects --type app
nx show projects --projects "apps/*"
nx show projects --withTarget build
Find affected projects
查找受影响的项目
nx show projects --affected --base=main
undefinednx show projects --affected --base=main
undefinedGet Project Information
获取项目信息
Critical: Always use for full resolved configuration. Do NOT read directly - it contains only partial configuration.
nx show project <name> --jsonproject.jsonbash
undefined重要提示:请始终使用获取完整的解析配置。请勿直接读取文件——它仅包含部分配置。
nx show project <name> --jsonproject.jsonbash
undefinedGet full configuration
获取完整配置
nx show project my-app --json
nx show project my-app --json
Extract targets
提取目标任务
nx show project my-app --json | jq '.targets | keys'
Configuration schemas:
- Workspace: `node_modules/nx/schemas/nx-schema.json`
- Project: `node_modules/nx/schemas/project-schema.json`nx show project my-app --json | jq '.targets | keys'
配置模式:
- 工作区:`node_modules/nx/schemas/nx-schema.json`
- 项目:`node_modules/nx/schemas/project-schema.json`Run Tasks
运行任务
bash
undefinedbash
undefinedRun specific project
运行指定项目
nx build web --configuration=production
nx build web --configuration=production
Run affected
运行受影响项目的任务
nx affected -t test --base=main
nx affected -t test --base=main
View dependency graph
查看依赖关系图
nx graph
undefinednx graph
undefinedWorkspace Architecture
工作区架构
workspace/
├── apps/ # Deployable applications
├── libs/ # Shared libraries
│ ├── shared/ # Shared across scopes
│ └── feature/ # Feature-specific
├── nx.json # Workspace configuration
└── tools/ # Custom executors/generatorsworkspace/
├── apps/ # 可部署应用程序
├── libs/ # 共享库
│ ├── shared/ # 跨范围共享
│ └── feature/ # 特定功能模块
├── nx.json # 工作区配置文件
└── tools/ # 自定义执行器/生成器Library Types
库类型
| Type | Purpose | Example |
|---|---|---|
| feature | Business logic, smart components | |
| ui | Presentational components | |
| data-access | API calls, state management | |
| util | Pure functions, helpers | |
| 类型 | 用途 | 示例 |
|---|---|---|
| feature | 业务逻辑、智能组件 | |
| ui | 展示型组件 | |
| data-access | API调用、状态管理 | |
| util | 纯函数、工具函数 | |
Detailed Resources
详细资源
Configuration: See reference/configuration.md for:
- nx.json templates and options
- project.json structure
- Module boundary rules
- Remote caching setup
Commands: See reference/commands.md for:
- Complete command reference
- Advanced filtering options
- Common workflows
CI/CD: See reference/ci-cd.md for:
- GitHub Actions configuration
- GitLab CI setup
- Jenkins, Azure Pipelines, CircleCI examples
- Affected commands in pipelines
Best Practices: See reference/best-practices.md for:
- Do's and don'ts
- Complete troubleshooting guide
- Performance optimization
- Migration guides
配置:请查看reference/configuration.md了解:
- nx.json模板及选项
- project.json结构
- 模块边界规则
- 远程缓存设置
命令:请查看reference/commands.md了解:
- 完整命令参考
- 高级过滤选项
- 常见工作流
CI/CD:请查看reference/ci-cd.md了解:
- GitHub Actions配置
- GitLab CI搭建
- Jenkins、Azure Pipelines、CircleCI示例
- 流水线中的受影响命令
最佳实践:请查看reference/best-practices.md了解:
- 注意事项(可做与不可做)
- 完整故障排除指南
- 性能优化
- 迁移指南
Common Workflows
常见工作流
"What's in this workspace?"
bash
nx show projects --type app # List applications
nx show projects --type lib # List libraries"How do I run project X?"
bash
nx show project X --json | jq '.targets | keys'"What changed?"
bash
nx show projects --affected --base=main"这个工作区里有什么?"
bash
nx show projects --type app # 列出应用程序
nx show projects --type lib # 列出库"如何运行项目X?"
bash
nx show project X --json | jq '.targets | keys'"哪些内容有变更?"
bash
nx show projects --affected --base=mainQuick Troubleshooting
快速故障排除
- Targets not showing: Use , not project.json
nx show project <name> --json - Affected not working: Ensure git history available (in CI)
fetch-depth: 0 - Cache issues: Run
nx reset
For detailed troubleshooting, see reference/best-practices.md.
- 目标任务未显示:请使用,而非直接查看project.json
nx show project <name> --json - 受影响项目分析功能失效:确保Git历史记录可用(CI中设置)
fetch-depth: 0 - 缓存问题:运行命令
nx reset
如需详细故障排除,请查看reference/best-practices.md。