We use cookies to enhance your experience on the site
CodeWorlds

Installing Angular CLI

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

Prerequisites

Before installation you need:

  • Node.js version 18.19 or newer
  • npm (installed together with Node.js)

Check versions:

1node --version
2# Should show v18.19.0 or newer
3
4npm --version
5# Should show 9.x or newer

Installing Angular CLI

Open the terminal and type:

1npm install -g @angular/cli

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

Verifying the Installation

1ng version

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

Creating Your First Project

1# Create a new project
2ng new my-dojo
3
4# CLI will ask:
5# ? Which stylesheet format would you like to use? (CSS, SCSS, Sass, Less)
6# ? Do you want to enable Server-Side Rendering (SSR)? (y/N)

Recommended answers for beginners:

  • Stylesheet: SCSS (greater flexibility)
  • SSR: No (we don't need it at the start)

Project Structure

After creating the project you will see:

1my-dojo/
2β”œβ”€β”€ src/
3β”‚   β”œβ”€β”€ app/
4β”‚   β”‚   β”œβ”€β”€ app.component.ts      # Main component
5β”‚   β”‚   β”œβ”€β”€ app.component.html    # Template
6β”‚   β”‚   β”œβ”€β”€ app.component.scss    # Styles
7β”‚   β”‚   β”œβ”€β”€ app.config.ts         # Configuration
8β”‚   β”‚   └── app.routes.ts         # Routing
9β”‚   β”œβ”€β”€ index.html                # Main HTML file
10β”‚   β”œβ”€β”€ main.ts                   # Entry point
11β”‚   └── styles.scss               # Global styles
12β”œβ”€β”€ angular.json                  # Project configuration
13β”œβ”€β”€ package.json                  # npm dependencies
14└── tsconfig.json                 # TypeScript configuration

Running the Application

1cd my-dojo
2ng serve

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

Useful flags:

1ng serve --open          # Automatically opens the browser
2ng serve --port 3000     # Changes the port
3ng serve --watch         # Automatic refresh (enabled by default)
Go to CodeWorlds→