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
boolean
default:"false"
Generate a routing module for the application
string
default:"css"
Stylesheet format:
css, scss, sass, less, or stylusboolean
default:"false"
Enable Server-Side Rendering (SSR) support
boolean
default:"false"
Skip initializing a git repository
boolean
default:"false"
Skip installing npm packages
string
Package manager to use:
npm, yarn, pnpm, or cnpmboolean
default:"true"
Create a new application in the workspace
Examples
ng serve
Start a development server with live reload.Options
Options
Examples
ng build
Build the application for deployment.Options
Options
string
Build configuration (e.g.,
production, development)string
Output directory for build artifacts
boolean
Enable optimization of the build output
boolean
Generate source maps
boolean
default:"true"
Ahead-of-Time compilation
boolean
default:"true"
Show build progress
boolean
default:"false"
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
Global Flags
These flags work with any command:boolean
Show help information (shorthand:
-h)boolean
Run command without making changes (shorthand:
-d)boolean
Force overwriting of files (shorthand:
-f)boolean
Skip importing into NgModule
string
Target project in multi-project workspace
Next Steps
Builders
Learn about custom build processes
Schematics
Create custom code generators
