How to install Angular?

Angular Installation is not as easy as Angular JS. In Angular JS, all we need to do is to install Angular JS CDN and use ng-app directive in html or any element. But its not in the case of Angular. Angular is a Developer platform built on TypeScript.

To install Angular, First install Node JS. Node JS comes with NPM. NPM is the package manager for node. So we have to use npm to install angular.


Install Angular CLI

Here is the step by step guide to install Angular. Make sure Node Js is already installed in your machine. If not, install nodejs first, and then follow below instructions.

Install Angular in Windows

npm i -g @angular/cli

Install Angular in Mac

sudo npm i -g @angular/cli

Install Angular in Linux

sudo npm i -g @angular/cli

Install Latest version of Angular

sudo npm i -g @angular/cli@latest

Install Specific version of Angular

sudo npm i -g @angular/cli@12.0.0

Check Angular Version

Once Angular is successfully installed, we can cross verify by checking angular version. To check angular version, type following command in terminal or cmd (in windows). This command is common for mac, windows and linux.


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 17.0.1
Node: 18.18.0
Package Manager: npm 9.8.1
OS: darwin x64   

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1700.1 (cli-only)
@angular-devkit/core         17.0.1 (cli-only)
@angular-devkit/schematics   17.0.1 (cli-only)
@schematics/angular          17.0.1 (cli-only)
ng version

Update Angular

In future, if we want to upgrade to latest angular version or degrade to previous version, we have to uninstall current version and install latest version. Here are the steps to update angular

Remove Angular

npm uninstall -g angular-cli

Clean Cache

npm cache clean

Install latest Angular

npm i -g @angular/cli@latest

Angular CLI Commands

Top Angular CLI Commands are given below.

CommendMeaning
ng buildCompile Angular Application
ng serveBuild and serve angular application with auto update
ng generategenerate and modify files
ng testRun Unit TEsting on project
ng e2eBuild and run angular application and run end-to-end tests.