Skip to the solution
EasyFrontend8 min read

What does the Angular CLI provide?

336 views

The problem

Question presented to candidate: "What does the Angular CLI do for a team, and what do ng new, ng generate, ng build, ng test and ng update actually give you today?"

What a strong answer should cover:

  • The CLI is the official command-line tool for creating, developing, building, testing and upgrading Angular workspaces.
  • ng new scaffolds a workspace with sensible defaults (in v22: standalone, zoneless, Vitest, esbuild application builder).
  • ng generate runs schematics to create components, services, guards and more in the project conventions.
  • ng serve / ng build use the esbuild-based @angular/build builders; production builds apply AOT, minification, hashing and budgets.
  • ng test runs unit tests (Vitest by default for new projects since v21); ng add installs and configures libraries; ng update upgrades with automatic migrations.
  • angular.json holds the architect targets (build, serve, test) the commands run.

Clarifying questions expected:

  • "Is this a new project, or an existing workspace that might still use the older webpack builder or Karma?"

Code / implementation expected: Optional β€” the command sequence for a new project and what each produces.

  • cli

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

8 min read Β· 9 sections

Read the code

A new Angular 22 project, start to finish (CLI 22.2.3)
# Angular CLI 22 workflow. Steps 1-5 were run with CLI 22.2.3; step 6 is shown, not run.
# (The CLI needs Node ^22.22.3, ^24.15.0 or >=26; it refuses older versions.)

# 1. Create a workspace: standalone, zoneless, Vitest, esbuild builder
npx @angular/cli@22 new demo --defaults --ssr=false
cd demo

# 2. Generate code from schematics (--dry-run shows the files without writing)
npx ng generate component user-card   # src/app/user-card/user-card.{ts,html,css,spec.ts}
npx ng generate service data          # src/app/data.ts
npx ng g c settings --dry-run          # short aliases: g = generate, c = component

# 3. Develop with a rebuild-on-save dev server (Vite underneath; http://localhost:4200 by default)
npx ng serve

# 4. Production build into dist/demo/, with hashed file names and size budgets
npx ng build

# 5. Unit tests (Vitest + jsdom in a new v22 project)
npx ng test --watch=false

# 6. Add a library through its schematic, and upgrade with migrations
npx ng add @angular/ssr
npx ng update @angular/core @angular/cli

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 10 of 121 in Angular

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

All Angular questions
Up nextEasy

What are standalone components?

Continue