Getting wrong version of angular-cli with npm

Viewed 2550

I want to install a specific version of angular(In particular 8.3.19). So, I run the command

npm install -g @angular/cli@8.3.19. Now, it is installed on my machine but when I do bg --version, I do see follwing:

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.803.29
@angular-devkit/build-angular   0.803.29
@angular-devkit/core            8.3.29
@angular-devkit/schematics      11.2.11
@angular/cdk                    8.2.3
@angular/cli                    11.2.11
@angular/material               8.2.3
@schematics/angular             11.2.11
@schematics/update              0.1102.11
rxjs                            6.4.0
typescript                      3.5.3
webpack                         4.42.1

which clearly states that angular cli version is 11.2.11, which not what I asked npm to install. I am not sure what I am doing wrong here. I am pretty new to npm and angular. Any suggestions?

1 Answers

If you have unintentionally installed the latest Angular globally and want to go back to a previous version of Angular CLI then try using the commands:

npm uninstall -g angular-cli
npm install -g @angular/cli@[whatever your version is]

(refer to https://www.npmjs.com/package/@angular/cli)

Then re-install dependencies from your package.json within your local project with:

npm install

There is really no need to downgrade the global version as you can install whatever previous versions of Angular in your local projects. In situations where you are installing an Angular project that has a higher version of the CLI than your global version, then in this case you would upgrade the global version, preferably to the latest possible as the packages in the latest Node.js library are backward compatible to previous versions, allowing you to create projects in the previous versions.

Related