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.
Steps to Create Projects with Different Angular Versions
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.
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
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
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 AngularCLI Package. 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
Step 5 : You can check the new project’s version by opening the package.json.
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.
Conclusion
Third Rock Techkno is a leading IT services company. We are a top-ranked web, voice and mobile app development company with over 10 years of experience. Client success forms the core of our value system.
We have expertise in the latest technologies, including Angular, React Native, iOS, Android, and more. Third Rock Techkno has developed smart, scalable, and innovative solutions for clients across a host of industries.
When you hire an Angular developer from our team, you benefit from our dedicated developers who combine their knowledge and skills to develop and deliver web and mobile apps that boost business and increase output for our clients.