In this article, we will upgrade from Angular to its latest version. Almost every 6-12 months, a new version of Angular is released. So to be up to date with the latest version is must needed step. You can find more about Angular CLI in its official documentation.
How to Update Angular CLI to Latest Version
You can check your current version of Angular CLI using the following command.
To update angular-cli to its latest version, use the following commands.
sudo npm uninstall -g angular-cli // For Mac npm uninstall -g angular-cli // For Windows Open Powershell on Administrator Mode
It will uninstall the angular-cli package globally from your computer or server.
Then we need to clear the cache using the following command.
sudo npm cache verify
If your npm version is < 5, you must hit the following command.
npm cache clean
Now, install the Angular CLI using the following command.
sudo npm install -g @angular/cli@latest
If your version is still old, then try the following command.
ng update @angular/cli
Now, check your Angular CLI version using the following command.
After updating both the global and local packages, clear the cache to avoid errors:
npm cache verify (recommended) npm cache clean (for older npm versions)
Update Angular Packages
Now you need to update the core packages/dependencies to Angular 7. Just run the following command:
ng update @angular/core
You can update RxJS using the ng update command:
ng update rxjs
ng new my-project cd my-project ng serve
You can see the updated Angular CLI version 7 by creating the new Angular project.
Now, when creating a new project, we got the following options, which are new in Angular 7.
When creating the Angular 7 project, we allowed the creation of the routing module. So it has the route file in the project folder.