What is Angular CLI?
Angular CLI (Command Line Interface) is the official tool for initializing, developing, scaffolding, and maintaining Angular applications. It provides a powerful set of commands that streamline the entire development workflow, from project creation to production deployment.Angular CLI Version: The current Angular framework version is 22.0.0-next.0, using CLI version 21.2.0-rc.2
Why Use Angular CLI?
Angular CLI offers several key advantages:Rapid Development
Generate components, services, and modules with a single command
Best Practices
Enforces Angular coding standards and project structure
Build Optimization
Production builds with tree-shaking, minification, and bundling
Developer Experience
Hot reload, live development server, and testing tools
Installation
Install Angular CLI globally using your preferred package manager:The Angular team recommends using pnpm as the package manager. The source repository uses pnpm version 10.30.3.
Verify Installation
Check that Angular CLI is installed correctly:Core Features
Project Generation
Create a new Angular workspace with a complete project structure:- Routing: Add Angular Router for navigation
- Stylesheet format: CSS, SCSS, Sass, Less, or Stylus
- SSR: Server-side rendering support
Development Server
Start a live development server with hot reload:Development Server Options
Development Server Options
--port: Specify custom port (default: 4200)--open: Automatically open browser--configuration: Use specific build configuration--host: Specify host address
Code Generation
Generate Angular artifacts using schematics:Building for Production
Create an optimized production build:- Ahead-of-Time (AOT) compilation
- Tree-shaking to remove unused code
- Minification and uglification
- Bundle optimization
- Source maps generation (optional)
Testing
Run unit tests with Karma and Jasmine:- Karma: Test runner
- Jasmine: Testing framework
- Code coverage reporting
- Watch mode for development
Project Structure
Angular CLI generates a standardized project structure:Build System
Angular CLI uses modern build tools:- @angular/build
- @angular-devkit/build-angular
The new application builder (v17+) uses esbuild and Vite for faster builds:
Configuration Files
angular.json
The workspace configuration file that defines:- Project structure and metadata
- Build configurations (development, production)
- Architect targets (build, serve, test)
- File replacements and assets
- Style preprocessor options
angular.json Schema
angular.json Schema
The configuration follows the schema at:Key sections:
version: Configuration schema versionnewProjectRoot: Directory for new projectsprojects: Project-specific configurationscli: CLI-wide settings (cache, analytics)
Package Manager Configuration
Angular CLI respects thepackageManager field in package.json:
CLI Analytics
Angular CLI can collect anonymous usage data to improve the tool:CLI Cache
Enable build caching for faster subsequent builds:Workspace Concepts
Single Project Workspace
Default setup with one application:Multi-Project Workspace
Host multiple applications and libraries:Next Steps
CLI Commands
Explore all available Angular CLI commands
Builders
Learn about custom build processes
Schematics
Create custom code generators
Configuration
Deep dive into angular.json configuration
Resources
Official CLI Docs
Complete CLI documentation
GitHub Repository
CLI source code and issues
