How to create projects with different Angular Versions?

Angular Development How to create projects with different Angular Versions?

Google’s opensource framework Angular is one of the leading javascript frameworks currently in the market. Google is taking this lead seriously and keeps upgrading it to get the best of javascript. But this comes a cost for the users, the developers working on the different project would have to work with multiple Angular versions in their system. Sadly, there is nothing like “Node Version Manager (NVM)” that can allow you to switch between versions of angular. But, there is a simple workaround that we are using at Third Rock Techkno. We install Angular-CLI in project folders and not globally.

I have demonstrated how we can do it in a Windows machine. You can follow a similar approach for whichever OS you are using.

You need to follow the steps below and you should have a local installation of Angular versions.

Step 1 : Create a folder in one of your local computer drives. I would like to create an Angular 4 project. For the demonstration, I have created the ‘angular-4-projects’ folder in my D Drive.

Angular Development

Step 2 : Open your cmd (Command prompt) and navigate to “angular-4-projects” that you recently created in the D drive of your machine. In my case, the path would be D:/angular-4-projects

Angular nvm

Step 3 : Now install Angular-CLI 1.4.x because that is the version that will install Angular 4 in to your project folder. You need to make sure while installation you are not using -g at the end of the installation command. If you use this -g than Angular- CLI 1.4.x will install globally on your machine. Here is the installing command syntax npm install @angular/cli@

Ex (For angular-4): npm install @angular/cli@1.4.x
Ex (For angular-5): npm install @angular/cli@1.5.x
Ex (For angular-6): npm install @angular/cli@6.x.x

Angular nvm

Note: After angular 6 the Angular-CLI version is the same as the Angular version.

Now, if you want to find which Angular-CLI version to use for which version of Angular you can find that here https://www.npmjs.com/package/@angular/cli. Once you land on the website you need to navigate to the versions tab and look into the documentation of the specific versions.

For the angular 4 i can use 1.6.x that come before 2 year from Now (Nov-2019)

Step 4 : Now create your angular version project inside that folder using command prompt.

ng new <project-name>

For demonstration, I am creating a project “angulr4demo”

ng new angular4demo

NodeJS Development

Step 5 : You can check the new project’s version by opening the package.json.

NodeJS Development

Now that you have seen how you can locally install the Angular-CLI that will allow you to run multiple Angular version in your system simultaneously, go ahead keep creating wonderful projects.

Reasons to upgrade to Angular 7 for Web App Development

Wondering how Angular 7 helps to boost your…

Read More