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:
- Best way to bundle an angular app for production deployment ?
- Type cannot be used as an index type.
- How to check your installed angular version ?
- Declare model class and use in Angular component : Typescript
- Add a Responsive Bootstrap Navigation Bar in Angular 9
- Set default value in the dropdown list in Angular 9
- Best way to delete components in Angular 9 with CLI ?
- HTML Property Binding in Angular : Data Binding
- Create custom events and fire in Angular 9 with EventEmitter – Example
- ERROR in multi /bootstrap.min.css ./src/styles.css in Angular 9
- Difference between declarations, providers, bootstrap and imports in @NgModule ?
- Angular CLI command to generate model in Angular 9
- Get index of ngFor element using index as value in attribute
- Dynamic and conditional CSS classes with ngClass : Angular
- Apply CSS style attribute dynamically with ngStyle : Angular 9
- This version of CLI is only compatible with Angular versions
- Global Angular CLI version is greater than your local version
- Display different colors for odd/even rows using ngFor loop and ngClass
- TrackBy with *ngFor in Angular 9 : Example
- Angular 9 Error : ‘app-header’ is not a known element
- How to Modularize Angular Application – Angular 9 ?