Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing a specific version of angular with angular cli

I searched through google and angular cli doc but couldn't find any way to install a specific version of Angular using Angular CLI. is it even possible?

like image 349
Sajad Avatar asked Apr 11 '17 11:04

Sajad


2 Answers

To answer your question, let's assume that you are interested in a specific angular version and NOT in a specific angular-cli version (angular-cli is just a tool after all).

A reasonnable move is to keep your angular-cli version alligned with your angular version, otherwise you risk to stumble into incompatibilities issues. So getting the correct angular-cli version will lead you to getting the desired angular version.

From that assumption, your question is not about angular-cli, but about npm.

Here is the way to go:

[STEP 0 - OPTIONAL] If you're not sure of the angular-cli version installed in your environment, uninstall it.

npm uninstall -g @angular/cli 

Then, run (--force flag might be required)

npm cache clean 

or, if you're using npm > 5.

npm cache verify 

[STEP 1] Install an angular-cli specific version

npm install -g @angular/[email protected] 

[STEP 2] Create a project

ng new you-app-name 

The resulting white app will be created in the desired angular version.

NOTE: I have not found any page displaying the compatibility matrix of angular and angular-cli. So I guess the only way to know what angular-cli version should be installed is to try various versions, create a new project and checkout the package.json to see which angular version is used.

angular versions changelog Here is the changelog from github reposition, where you can check available versions and the differences.

Hope it helps

like image 126
avi.elkharrat Avatar answered Sep 22 '22 18:09

avi.elkharrat


You can just have package.json with specific version and do npm install and it will install that version.

Also you don't need to depend on angular-cli to develop your project.

like image 27
Mario Petrovic Avatar answered Sep 22 '22 18:09

Mario Petrovic