Command Overview
Angular CLI provides a comprehensive set of commands for every stage of development. All commands follow the pattern:Use
ng <command> --help to see detailed options for any command.Essential Commands
ng new
Create a new Angular workspace and application.Options
Options
Generate a routing module for the application
Stylesheet format:
css, scss, sass, less, or stylusEnable Server-Side Rendering (SSR) support
Skip initializing a git repository
Skip installing npm packages
Package manager to use:
npm, yarn, pnpm, or cnpmCreate a new application in the workspace
Examples
ng serve
Start a development server with live reload.Options
Options
Port to listen on
Host to listen on
Automatically open browser (shorthand:
-o)Build configuration to use (shorthand:
-c)Serve using HTTPS
Path to proxy configuration file
Examples
ng build
Build the application for deployment.Options
Options
Build configuration (e.g.,
production, development)Output directory for build artifacts
Enable optimization of the build output
Generate source maps
Ahead-of-Time compilation
Show build progress
Run build when files change
Examples
Build Output
Production builds include:- AOT Compilation: Templates compiled ahead-of-time
- Tree Shaking: Unused code removed
- Minification: Code size reduced
- Bundle Optimization: Efficient chunking
Default output directory is
dist/ (configurable in angular.json)ng generate
Generate Angular artifacts using schematics.Available Schematics
- Component
- Service
- Module
- Directive
- Pipe
- Guard
- Interface
- Class
--standalone: Create standalone component (default in v17+)--skip-tests: Skip test file generation--inline-template: Use inline template--inline-style: Use inline styles--flat: Don’t create a folder--export: Export from parent module
ng test
Run unit tests using Karma and Jasmine.Options
Options
Examples
The Angular team uses Karma 6.4.0 and Jasmine 6.1.0 for testing.
ng e2e
Run end-to-end tests (requires e2e test setup).ng lint
Run linting tools on Angular app code.Requires ESLint or TSLint configuration. The Angular team uses TSLint 6.1.3 in the source repository.
ng update
Update Angular packages and dependencies.Examples
Update Options
Update Options
ng add
Add external libraries to your project with automatic configuration.Popular Packages
The
ng add command automatically installs packages and runs configuration schematics.ng version
Display Angular CLI and package versions.- Angular CLI version
- Node.js version
- Package manager version
- TypeScript version
- Angular package versions
ng config
Get or set Angular configuration values.Examples
ng analytics
Manage Angular CLI analytics settings.- Enable
- Disable
- Info
- Prompt
ng extract-i18n
Extract internationalization messages from templates.Options
Options
Example
Migration Commands
Angular provides several migration schematics:- Standalone Migration
- Control Flow Migration
- Signal Inputs
- Signal Queries
Convert to standalone components:Options:
- Convert declarations to standalone
- Remove unnecessary NgModules
- Switch to standalone bootstrapping
Command Aliases
Common Shortcuts
| Full Command | Alias | Description |
|---|---|---|
ng generate | ng g | Generate schematics |
ng serve --open | ng s -o | Serve and open browser |
ng build --configuration=production | ng b -c production | Production build |
ng test | ng t | Run tests |
ng version | ng v | Show version |
Global Flags
These flags work with any command:Show help information (shorthand:
-h)Run command without making changes (shorthand:
-d)Force overwriting of files (shorthand:
-f)Skip importing into NgModule
Target project in multi-project workspace
Next Steps
Builders
Learn about custom build processes
Schematics
Create custom code generators
