Skip to main content

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.
boolean
default:"false"
Generate a routing module for the application
string
default:"css"
Stylesheet format: css, scss, sass, less, or stylus
boolean
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 cnpm
boolean
default:"true"
Create a new application in the workspace

Examples


ng serve

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

Examples

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

ng build

Build the application for deployment.
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

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:
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.
boolean
default:"true"
Watch files for changes and re-run tests
boolean
default:"false"
Generate code coverage report
string
Browsers to run tests in (e.g., Chrome, Firefox)
string
Glob pattern for test files to include

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).
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.
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

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

ng add

Add external libraries to your project with automatic configuration.
The ng add command automatically installs packages and runs configuration schematics.

ng version

Display Angular CLI and package versions.
Outputs:
  • 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.

ng extract-i18n

Extract internationalization messages from templates.
string
default:"xlf"
Output format: xlf, xlf2, xmb, json, arb
string
Output directory for translation files
string
Output file name

Example


Migration Commands

Angular provides several migration schematics:
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