# Update angular to latest version

https://update.angular.io/ is a great place to understand and follow for updating angular from one version to a new one, but some time things don't work as expected. for example, when we have a package which doesn't support the latest angular, we get an exception  

> × Migration failed: Incompatible peer dependencies found.
> Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
> You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
>   See "C:\Users\...\angular-errors.log" for further details.

Below are the steps that I follow which works.
For this example I am mentioning the steps for updating from v12 to v14  

`npm update`  

`npx  @angular/cli@13 update @angular/core@13 @angular/cli@13 --force`  

commit your changes! else on the next update you will get an error  
> Error: Repository is not clean. Please commit or stash any changes before updating.
  
`npx  @angular/cli@14 update @angular/core@14 @angular/cli@14 --force`  

commit  again

Now we use [npm-check-updates](https://www.npmjs.com/package/npm-check-updates) or `npm` itself to update all the depend packages which needs to be updated

`npx npm-check-updates -i`
 or
`npm install {package-name}@* {save flags?}`

then 

`npm audit fix`  

Now try running your application. `npm start`


*Happy Coding!*

-------


Some additional commands and reference materials  
`npm clean-install` to clear the node_modules folder and install fresh  
[how-to-update-npm-dependencies](https://www.freecodecamp.org/news/how-to-update-npm-dependencies/)




