Skip to main content

Command Overview

Angular CLI provides a comprehensive set of commands for every stage of development. All commands follow the pattern:
ng <command> [options]
Use ng <command> --help to see detailed options for any command.

Essential Commands

ng new

Create a new Angular workspace and application.
ng new <project-name> [options]
--routing
boolean
default:"false"
Generate a routing module for the application
--style
string
default:"css"
Stylesheet format: css, scss, sass, less, or stylus
--ssr
boolean
default:"false"
Enable Server-Side Rendering (SSR) support
--skip-git
boolean
default:"false"
Skip initializing a git repository
--skip-install
boolean
default:"false"
Skip installing npm packages
--package-manager
string
Package manager to use: npm, yarn, pnpm, or cnpm
--create-application
boolean
default:"true"
Create a new application in the workspace

Examples

ng new my-app

ng serve

Start a development server with live reload.
ng serve [options]
--port
number
default:"4200"
Port to listen on
--host
string
default:"localhost"
Host to listen on
--open
boolean
default:"false"
Automatically open browser (shorthand: -o)
--configuration
string
Build configuration to use (shorthand: -c)
--ssl
boolean
default:"false"
Serve using HTTPS
--proxy-config
string
Path to proxy configuration file

Examples

ng serve
The development server is available at http://localhost:4200 by default.

ng build

Build the application for deployment.
ng build [options]
--configuration
string
Build configuration (e.g., production, development)
--output-path
string
Output directory for build artifacts
--optimization
boolean
Enable optimization of the build output
--source-map
boolean
Generate source maps
--aot
boolean
default:"true"
Ahead-of-Time compilation
--progress
boolean
default:"true"
Show build progress
--watch
boolean
default:"false"
Run build when files change

Examples

ng build

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.
ng generate <schematic> <name> [options]
ng g <schematic> <name> [options]  # shorthand

Available Schematics

ng generate component <name>
Options:
  • --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
Example:
ng g component user-profile --standalone
For standalone components, directives, and pipes, use the --standalone flag or set it as default in angular.json.

ng test

Run unit tests using Karma and Jasmine.
ng test [options]
--watch
boolean
default:"true"
Watch files for changes and re-run tests
--code-coverage
boolean
default:"false"
Generate code coverage report
--browsers
string
Browsers to run tests in (e.g., Chrome, Firefox)
--include
string
Glob pattern for test files to include

Examples

ng test
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 e2e [options]
Starting with Angular v12, e2e testing is not included by default. You need to add a third-party e2e testing tool like Cypress or Playwright.

ng lint

Run linting tools on Angular app code.
ng lint [options]
Requires ESLint or TSLint configuration. The Angular team uses TSLint 6.1.3 in the source repository.

ng update

Update Angular packages and dependencies.
ng update [packages]

Examples

ng update
--force
boolean
Force update even if there are peer dependency warnings
--migrate-only
boolean
Only run migrations, don’t update packages
--from
string
Version to migrate from
--to
string
Version to migrate to

ng add

Add external libraries to your project with automatic configuration.
ng add <package>
ng add @angular/material
The ng add command automatically installs packages and runs configuration schematics.

ng version

Display Angular CLI and package versions.
ng version
ng v  # shorthand
Outputs:
  • Angular CLI version
  • Node.js version
  • Package manager version
  • TypeScript version
  • Angular package versions

ng config

Get or set Angular configuration values.
ng config <key> [value]

Examples

ng config cli.analytics

ng analytics

Manage Angular CLI analytics settings.
ng analytics <command>
ng analytics on

ng extract-i18n

Extract internationalization messages from templates.
ng extract-i18n [options]
--format
string
default:"xlf"
Output format: xlf, xlf2, xmb, json, arb
--output-path
string
Output directory for translation files
--out-file
string
Output file name

Example

ng extract-i18n --format=xlf2 --output-path=src/locale

Migration Commands

Angular provides several migration schematics:
Convert to standalone components:
ng generate @angular/core:standalone
Options:
  • Convert declarations to standalone
  • Remove unnecessary NgModules
  • Switch to standalone bootstrapping

Command Aliases

Common Shortcuts
Full CommandAliasDescription
ng generateng gGenerate schematics
ng serve --openng s -oServe and open browser
ng build --configuration=productionng b -c productionProduction build
ng testng tRun tests
ng versionng vShow version

Global Flags

These flags work with any command:
--help
boolean
Show help information (shorthand: -h)
--dry-run
boolean
Run command without making changes (shorthand: -d)
--force
boolean
Force overwriting of files (shorthand: -f)
--skip-import
boolean
Skip importing into NgModule
--project
string
Target project in multi-project workspace

Next Steps

Builders

Learn about custom build processes

Schematics

Create custom code generators

Build docs developers (and LLMs) love