Angular course Β· Module 1: Introduction to Angular
Installing Angular CLI
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 newerInstalling Angular CLI
Open the terminal and type:
npm install -g @angular/cliThe -g flag means global installation - the CLI will be available from anywhere in the system.
Verifying the Installation
ng versionYou 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)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:
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 configurationNote: 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 serveThe 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. Which command is used to create a new Angular project?
2. Which command starts the Angular development server?
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