How to install a specific version of Angular with Angular CLI?
AngularAngular CliAngular Problem Overview
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?
Angular Solutions
Solution 1 - Angular
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/cli@wished.version.here
[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
Solution 2 - Angular
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.
Solution 3 - Angular
> Edit #2 ( 7/2/2017)
If you install the angular cli right now, you'd probably have the new name of angular cli which is @angular/cli
, so you need to uninstall it using
npm uninstall -g @angular/cli
and follow the code above. I'm still getting upvotes for this so I updated my answer for those who want to use the older version for some reasons.
> Edit #1
If you really want to create a new project with previous version of Angular using the cli, try to downgrade the angular-cli before the final release. Something like:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@1.0.0-beta.32
> Initial
You can change the version of the angular in the package.json . I'm guessing you want to use older version of angular but I suggest you use the latest version. Using:
ng new app-name
will always use the latest version of angular.
Solution 4 - Angular
The angular/cli
versions and their installed angular/compiler
versions:
- 1.0 - 1.4.x = ^4.0.0
- 1.5.x = ^5.0.0
- 1.6.x - 1.7.x = ^5.2.0
- 6.x = ^6.0.0
- 7.x = ^7.0.0
Can be confirmed by reviewing the angular/cli
's package.json
file in the repository newer repository master repository. One would have to install the specific cli version to get the specific angular version:
npm -g install @angular/cli@1.5.* # For ^5.0.0
Solution 5 - Angular
Yes, it's possible to install a specific version of Angular using npm:
npm install -g @angular/cli@8.3.19
Next, you need to use the ng new command to create an Angular project based on the specific version you used when installing the CLI:
ng new your-project-name
This will generate a project based on Angular v8.3.19, the version which was specified when installing Angular CLI.
Solution 6 - Angular
Use the following command to install and downgrade the specific version.
uninstall cli
npm uninstall -g @angular/cli
clean npm cache
npm cache clean --force
install cli
npm install -g @angular/cli@_choose_your_version
Solution 7 - Angular
npx @angular/cli@10 new my-poject
you can replace 10 with your version of choice... no need to uninstall your existing CLI! Just learnt that now...
Solution 8 - Angular
Specify the version you want in the 'dependencies' section of your package.json, then from your root project folder in the console/terminal run this:
npm install
For example, the following will specifically install v4.3.4
"dependencies": {
"@angular/common": "4.3.4",
"@angular/compiler": "4.3.4",
"@angular/core": "4.3.4",
"@angular/forms": "4.3.4",
"@angular/http": "4.3.4",
"@angular/platform-browser": "4.3.4",
"@angular/platform-browser-dynamic": "4.3.4",
"@angular/router": "4.3.4",
}
You can also add the following modifiers to the version number to vary how specific you need the version to be:
caret ^
Updates you to the most recent major version, as specified by the first number:
^4.3.0
will load the latest 4.x.x release, but will not load 5.x.x
tilde ~
Update you to the most recent minor version, as specified by the second number:
~4.3.0
will load the latest 4.3.x release, but will not load 4.4.x
Solution 9 - Angular
npm i -g @angular/[email protected]
x,y,z--> ur desired version number
Solution 10 - Angular
If you still have problems and are using nvm make sure to set the nvm node environment.
To select the latest version installed. To see versions use nvm list
.
nvm use node
sudo npm remove -g @angular/cli
sudo npm install -g @angular/cli
Or to install a specific version use:
sudo npm install -g @angular/cli@7.2
If you dir permission errors use:
sudo npm install -g @angular/cli@7.2 --unsafe-perm
Solution 11 - Angular
I have Angular 11 installed globally on my computer, but I needed to create a new project in Angular 6. Based on the CLI version to Angular version info in Robert Brisita's answer on this question, these steps did it for me:
created [angular-six-dir]
cd [angular-six-dir]
npm install @angular/cli@6.*
ng new [angular-six-project-name]
Solution 12 - Angular
Execute this command in the command prompt and you will be good to go
npm install -g @angular/cli@version_name
Solution 13 - Angular
use the following command to install the specific version. say you want to install angular/cli version 1.6.8 then enter the following command :
sudo npm install -g @angular/cli@1.6.8
this will install angular/cli version 1.6.8
Solution 14 - Angular
npm install -g @angular/cli@6.1.1
##Then you can check the version by##
ng --version
Solution 15 - Angular
This work for me.
Open CMD in folder "C:\Users\YourUser\source\repos"
npm uninstall -g @angular/cli
npm cache clean
npm cache verify
npm install -g @angular/cli
Try again after that.
Solution 16 - Angular
I would suggest using NVM to keep different versions of node and npm and then install the compatible angular-cli
Solution 17 - Angular
Use CMD run as administrator, command like this
npm i @angular/cli@11.2.18
npm i -g @angular/cli@11.2.18
npm install @angular/cli@11.2.18
npm install -g @angular/cli@11.2.18
Get exist version like this https://www.npmjs.com/package/@angular/cli/v/12.2.16