LearnAI ToolsCareerPractice BuildsPlayContact
Lesson 614 min read

Installing Angular (Angular CLI)

Scaffold a new Angular project using the Angular CLI and understand every setup prompt it asks.

Installing the Angular CLI

The Angular CLI is a command-line tool for generating, building, testing, and running Angular projects. Install it globally once, and it's available for every project afterward.

npm install -g @angular/cli

Creating a Project

ng new my-app
cd my-app
ng serve

Understanding the Setup Prompts

PromptRecommended AnswerWhy
Which stylesheet format?CSSSimplest choice for this course; Sass/Less work identically if you prefer them.
Enable Server-Side Rendering (SSR)?No (for now)SSR with Angular Universal is covered in its own dedicated lesson later.
Would you like to add Angular routing?YesSets up the Angular Router from the start — this course uses it from early on.

Running the Dev Server

ng serve
# Local: http://localhost:4200/
Browser Result

Click Run to see what this code prints.

Live Reload

Edit a component file and save — the browser automatically reloads to reflect your change, thanks to the Angular CLI's built-in dev server.

Available CLI Commands

  • ng serve — starts the development server with live reload.
  • ng build — creates an optimized production build.
  • ng generate component my-component — scaffolds a new component with all its files.
  • ng test — runs the project's unit tests.

Common Beginner Mistakes

Installing the CLI locally instead of globally, then forgetting npx

Without a global install, run commands with npx ng serve instead of ng serve, or install globally as shown above to use ng directly.

Editing files inside dist/

That folder is generated output from ng build — any edits there are overwritten on the next build.

FAQs

Port 4200 by default — pass --port to use a different one.

Yes — ng generate and ng add can retrofit many features into an existing project, not just at creation time.

Summary

You now have a running Angular project, scaffolded and managed through the Angular CLI. Next, you'll take a tour of the folders and files it generated.

Next Lesson →

Project Structure