angular tutorials

How to upgrade Angular CLI to the latest version Angular 9 or 10 ?

This tutorial guides you on how to upgrade Angular CLI to the latest version Angular 9 or 10. Let’s see how to update angular-cli package installed globally in your system as well as the local project’s angular-cli.

Upgrade Angular CLI to the latest version Angular 9 or 10

To upgrade angular CLI package to the latest version Angular 9 or 10 globally in your system, you need to run the following command.

sudo npm uninstall -g angular-cli @angular/cli
sudo npm cache clean --force
sudo npm install -g @angular/cli@latest

Note, only use “sudo” in case of Mac/ Linux.

And to update the local project’s angular-cli package version, you need to run the following npm commands. This is required since inside your project directory the local angular-cli package version will be given higher priority compared to the global one. Therefore, you are required to update the local project’s angular-cli version too.

sudo rm -rf node_modules dist
sudo npm uninstall --save-dev angular-cli
sudo npm install --save-dev @angular/cli@latest
sudo npm install
sudo ng update

That’s it. You had upgrade Angular CLI to the latest version Angular 9 or 10.

Once you update your CLI, you can update Angular version also. To update the Angular Version please check Angular Update Guide.

Recommendation – Update Angular CLI to the latest version

Note, you need to remember few things while upgrading to Angular 10 version and before running ng update command.

  • It is always recommended to update your angular app to its next major angular version.
  • For example, if you are using Angular 7 or 8 or any other lower versions, DO NOT try to update to Angular 10 version directly.
  • First, update lower versions of Angular app to Angular 9.
  • Then use ng update command.

Updating your app to Angular 10 version is easy if your Angular version is 9.

You just need to run the following command to update angular-cli version. The below ng update command will update @angular/core and @angular/cli.

ng update @angular/core @angular/cli

If you are using Angular material, then you have to update it as well using the following ng update command.

Again, if you are using older version of Angular application other than version 9. Then its recommended to update to Angular 9 first, then upgrade to version 10 after that.

Hope it helped 🙂

Also See:

References:

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments