Resolution
We get this error because of the difference in Angular CLI installed globally Vs local project workspace.
It happens mostly when we are trying to migrate an older Angular framework (Example- Angular 5 or 6 or 7 or 8 apps to Latest (Ex. Angular 9 or 10, or 11).
Steps to fix the issue
Update Angular CLI for a workspace (Local)
npm install --save --only=dev @angular/cli@latest
Make sure to install the global version using the command with ‘-g’
npm install -g @angular/cli@latest
Run Update command to get a list of all dependencies required to be upgraded.
ng update
Next Run update command as below for each individual Angular core package
ng update @angular/cli @angular/core
However (sometimes), we will have to add ‘–force’ and ‘–allow-dirty’ flags command additionally to fix all other pending issues.
ng update @angular/cli @angular/core --allow-dirty --force