0
0
AngularHow-ToBeginner · 3 min read

How to Install Angular CLI: Step-by-Step Guide

To install Angular CLI, run npm install -g @angular/cli in your terminal. This command installs the CLI globally, allowing you to create and manage Angular projects easily.
📐

Syntax

The basic syntax to install Angular CLI globally is:

  • npm: Node Package Manager used to install packages.
  • install: Command to add a package.
  • -g: Flag to install the package globally on your system.
  • @angular/cli: The Angular CLI package name.
bash
npm install -g @angular/cli
💻

Example

This example shows how to install Angular CLI globally and check its version to confirm the installation.

bash
npm install -g @angular/cli
ng version
Output
Angular CLI: 16.2.5 Node: 20.2.0 Package Manager: npm 9.6.7 OS: your-operating-system Angular: 16.2.0 ... (other Angular packages versions)
⚠️

Common Pitfalls

Common mistakes when installing Angular CLI include:

  • Not using -g flag, which installs CLI only locally and makes commands unavailable globally.
  • Running the command without administrator or root permissions, causing permission errors.
  • Using an outdated Node.js or npm version, which can cause installation failures.
  • Not verifying the installation by checking the CLI version.
bash
Wrong (local install):
npm install @angular/cli

Right (global install):
npm install -g @angular/cli
📊

Quick Reference

Summary tips for installing Angular CLI:

  • Use npm install -g @angular/cli to install globally.
  • Ensure Node.js and npm are up to date (Node.js 20+ recommended).
  • Run terminal as administrator or use sudo on macOS/Linux if permission errors occur.
  • Verify installation with ng version.

Key Takeaways

Install Angular CLI globally using npm install -g @angular/cli for easy access.
Make sure Node.js and npm are updated to avoid installation issues.
Use administrator or root permissions if you face permission errors during installation.
Verify the installation by running ng version to check the installed CLI version.