What the Angular CLI Is and Why You Need It
The Angular CLI (@angular/cli) is the official command-line tool for creating, building, testing, and deploying Angular applications. It automates project scaffolding, enforces consistent project structure, and provides optimized build pipelines out of the box.
Without the CLI you would manually configure webpack, TypeScript compilation, testing frameworks, and development servers. The CLI handles all of this so you can focus on writing application code.
Prerequisites
Before installing the CLI you need:
- Node.js — Angular 17+ requires Node.js 18.13 or later (LTS recommended)
- npm — bundled with Node.js, used to install the CLI package
Verify your Node.js version:
node --version
# v18.19.0 or v20.x.x or v22.x.x
npm --version
# 9.x or 10.x
Installing the CLI
npm install -g @angular/cli
The -g flag installs globally so the ng command is available in any directory. On macOS or Linux you may need sudo if your global npm directory requires elevated permissions.
Verifying the Installation
ng version
You should see output listing the CLI version, Node version, and package manager version:
Angular CLI: 17.1.0
Node: 20.11.0
Package Manager: npm 10.2.3
Common Installation Issues
Permission errors on macOS/Linux:
# Fix npm global directory permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
# Add ~/.npm-global/bin to your PATH
Node.js version too old:
# Check your version
node --version
# Upgrade via nvm
nvm install 20
nvm use 20
Corrupted global install:
npm uninstall -g @angular/cli
npm cache clean --force
npm install -g @angular/cli
Essential CLI Commands to Know
Once installed, the CLI provides a set of commands you will use throughout development:
| Command | Purpose |
|---|---|
ng new <name> |
Create a new Angular workspace |
ng serve |
Start the dev server with live reload |
ng build |
Compile the app for production |
ng generate <schematic> |
Generate components, services, etc. |
ng test |
Run unit tests |
ng lint |
Run the linter |
ng add <package> |
Add a library to your project |
Updating the CLI
# Update global CLI
npm install -g @angular/cli@latest
# Update local project CLI
ng update @angular/cli @angular/core
Uninstalling
npm uninstall -g @angular/cli
The CLI is a development dependency — it is not included in your production build output. Your deployed application consists of static HTML, CSS, and JavaScript files.
Quiz
1. What is the minimum Node.js version required for Angular 17+?
2. Which command installs the Angular CLI globally?
3. How do you verify the Angular CLI is installed correctly?
Flashcards
Question
What does the Angular CLI do?
Click to reveal answer
Answer
Automates project scaffolding, building, testing, and deployment of Angular applications. It handles webpack config, TypeScript compilation, and dev server setup.
Question
How do you install the Angular CLI?
Click to reveal answer
Answer
npm install -g @angular/cli — the -g flag makes it globally available.
Question
What Node.js version does Angular 17+ require?
Click to reveal answer
Answer
Node.js 18.13 or later (LTS recommended).
Revision Notes
Key Takeaways
- 1. Angular CLI is installed globally via npm install -g @angular/cli
- 2. Node.js 18.13+ is required for Angular 17+
- 3. ng version confirms the installation
- 4. The CLI is a dev dependency — not included in production builds
Interview Tips
- • Mention that the CLI abstracts webpack and TypeScript configuration
- • Be ready to explain why global vs local installation matters
- • Know how to troubleshoot permission and version issues
Cheat Sheet
Angular CLI Installation Cheat Sheet
Install:
npm install -g @angular/cli
Verify:
ng version
Requirements:
- Node.js 18.13+
- npm 9.x+
Key commands:
ng new <name>— create projectng serve— dev serverng build— production buildng generate— scaffold code
Fix permission errors:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Continue Learning
Before You Start
- No prerequisites listed.