The Angular CLI

Generate, Build, Test From One Tool

The Angular CLI

The Angular CLI is the workhorse that handles scaffolding, the dev server, production builds, tests, and code generation.

4 min read Level 1/5 #angular#cli#tooling
What you'll learn
  • Run ng serve, ng build, and ng test
  • Generate code with ng generate
  • Upgrade dependencies with ng update

The ng command is the front door to every Angular workflow. Most teams never touch webpack or Vite configs directly — they let the CLI handle it.

Running the App

ng serve          # dev server with HMR at :4200
ng serve --port 5000 --open
ng build          # production bundle into dist/
ng test           # unit tests (Karma/Jasmine or Jest)
ng e2e            # end-to-end tests (if configured)

ng build runs in production mode by default in Angular 20+: tree-shaken, minified, with hashed file names ready to deploy to any static host.

Generating Code

The biggest time-saver. ng generate (alias ng g) creates files with the right boilerplate and wires them into the imports they need.

ng g component features/user-card
ng g service core/api
ng g directive shared/autofocus
ng g pipe shared/truncate
ng g guard auth/auth

The shorthand ng g c user-card works too. Generated components are standalone by default in Angular 20+.

Updating

ng update                       # see what's outdated
ng update @angular/core @angular/cli

ng update doesn’t just bump versions — it runs migration schematics that rewrite your code to match newer APIs. That’s how you survive major upgrades without sobbing.

Project Structure →