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.
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 @email@example.com Ex (For angular-5): npm install @firstname.lastname@example.org Ex (For angular-6): npm install @email@example.com
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
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.