Installing the Angular CLI
The Angular CLI (ng) is the command-line tool that creates projects, generates components, runs a dev server, and builds your app for production. You will use it constantly throughout this course.
Prerequisites
Section titled “Prerequisites”The Angular CLI runs on Node.js. If you completed the TypeScript Foundations course, Node.js is already installed. Verify:
node --versionnpm --versionBoth commands should print version numbers. Node 18 or higher is required for Angular 21. If you need to install Node.js, download the LTS release from nodejs.org.
Installing the CLI
Section titled “Installing the CLI”Install the Angular CLI globally so the ng command is available anywhere on your system:
npm install -g @angular/cliVerify the installation:
ng versionYou should see output like this:
_ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/
Angular CLI: 21.x.xNode: 22.x.xPackage Manager: npm 10.x.xOS: linux x64The exact versions will differ. What matters is that the command runs without error.
What the CLI does
Section titled “What the CLI does”The Angular CLI wraps a build system (webpack or esbuild depending on the version) and a code generation system. Its most important commands:
| Command | What it does |
|---|---|
ng new <name> | Scaffold a new Angular project |
ng serve | Start the dev server with live reload |
ng build | Build the app for production |
ng generate component <name> | Generate a new component |
ng generate service <name> | Generate a new service |
You will use all of these in this course. For now, just make sure the CLI is installed.
Exercise
Section titled “Exercise”- Run
npm install -g @angular/clito install the CLI. - Run
ng versionand confirm it prints the Angular CLI version without errors. - Run
ng helpand scan the list of available commands. You do not need to understand them yet — just note which ones exist.
- The Angular CLI is installed globally with
npm install -g @angular/cli. - Verify with
ng version— it should print the CLI and Node.js versions. - Node.js 18 or higher is required for Angular 21.
- The CLI handles project scaffolding, code generation, the dev server, and production builds.