Angular course Β· Module 1: Introduction to Angular

Installing Angular CLI

2 min read Β·
In this lesson5

Angular CLI (Command Line Interface) is your forge - a tool for creating, building, and managing Angular projects.

Prerequisites

Before installation you need:

  • Node.js in the current LTS version (22.12 or newer; the latest Angular CLI no longer runs on Node.js 18)
  • npm (installed together with Node.js)

Check versions:

node --version
# Should show v22.12.0 or newer

npm --version
# Should show 10.x or newer

Installing Angular CLI

Open the terminal and type:

npm install -g @angular/cli

The -g flag means global installation - the CLI will be available from anywhere in the system.

Verifying the Installation

ng version

You should see information about the installed Angular CLI version and supported Node.js and TypeScript versions.

Creating Your First Project

# Create a new project
ng new my-dojo

# CLI will ask:
# ? Which stylesheet format would you like to use? (CSS, SCSS, Sass, Less)
# ? Do you want to enable Server-Side Rendering (SSR)? (y/N)
  • Stylesheet: SCSS (greater flexibility)
  • SSR: No (we don't need it at the start)

Project Structure

After creating the project you will see:

my-dojo/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ app.component.ts      # Main component
β”‚   β”‚   β”œβ”€β”€ app.component.html    # Template
β”‚   β”‚   β”œβ”€β”€ app.component.scss    # Styles
β”‚   β”‚   β”œβ”€β”€ app.config.ts         # Configuration
β”‚   β”‚   └── app.routes.ts         # Routing
β”‚   β”œβ”€β”€ index.html                # Main HTML file
β”‚   β”œβ”€β”€ main.ts                   # Entry point
β”‚   └── styles.scss               # Global styles
β”œβ”€β”€ angular.json                  # Project configuration
β”œβ”€β”€ package.json                  # npm dependencies
└── tsconfig.json                 # TypeScript configuration

Note: since Angular 20 the CLI creates files without the .component suffix - instead of app.component.ts you will see app.ts with the App class, and app.html instead of app.component.html. The files play the same roles.

Running the Application

cd my-dojo
ng serve

The application will be available at: http://localhost:4200

Useful flags:

ng serve --open          # Automatically opens the browser
ng serve --port 3000     # Changes the port
ng serve --watch         # Automatic refresh (enabled by default)

Spotted a mistake in this lesson?

Check yourself

Answer the questions from this lesson. Pick an answer to see right away whether it is correct.

  1. 1. Which command is used to create a new Angular project?

  2. 2. Which command starts the Angular development server?

  3. 3. At which address is an Angular application available by default after running 'ng serve'?

Hands-on tasks in the game

  • Horizontal ordering

    Arrange in one line the command to install the Angular CLI globally:

  • Vertical ordering

    Order the steps to create and run a new Angular project (from top to bottom):

  • Click in order

    Click in order to build the command that checks the Angular version: ng version

Useful articles