How To Install Multiple Versions Of Angular On The Same System

Introduction

In this article, we are going to discuss “how to install multiple Angular versions on the same computer”

This is an important interview question that was asked by many reputed IT companies.

USECASE

Google’s team is working hard to make Angular better and better and for that, they are releasing new versions frequently. Many times we fall into a situation where we have two projects developed in two different versions, and we need to support both.

This situation raises the requirement to install two different versions on the same computer.

Suppose we have 2 different projects like below

  1. Project 1 – Angular 12 – Install Locally.
  2. Project 2 – Angular 13 - Install Globally

In this case, we need two different versions to run both projects correctly.

We can do that using NVM. NVM permits us to do so. But here we are going to discuss using Angular CLI which is a more preferable way.

How to Install Multiple Angular Versions?

STEP 1 - Use the below command to install Angular 13 Globally.

npm install -g @angular/cli

Install Multiple Angular Versions

Once Installation is done, we will check the version using the below command,

ng --version

Install Multiple Angular Versions

I assume that you are already aware of how to create an Angular project, as the scope of this article is how to install multiple versions.

STEP 2 - Please create a project using Angular 13. If you don’t know then please create a project using the command mentioned in step 5. Kindly refer to this article to set up/install and create a project.

Create Project Folder for Angular Version 12.

Install Multiple Angular Versions

STEP 3 - Open Command Prompt and set the working directory to “Angular12.1”.

Install Multiple Angular Versions

STEP 4 - Now install angular 12 locally using the below command.

Install Multiple Angular Versions

STEP 5- Create a new project using the below command,

ng new “Angular122Project”

Below screen appear, once created successfully 

Install Multiple Angular Versions

STEP 6 - Execute Angular 12 Project using the below command. As we have created Angular 13 on port 4200. We will give a new port to Angular 12.

ng serve --port 4002

Install Multiple Angular Versions

Let's browse URL given in the above screen,

Install Multiple Angular Versions

STEP 7 - I assume that we have created the Angular 13 Project using the above steps which are running at port 4200.

Install Multiple Angular Versions

Let's browse the Angular 13 application using the given URL in the above image.

Install Multiple Angular Versions

That’s all for this article. Hope you enjoyed it and find it useful.


Similar Articles