Fix The Angular Compiler requires TypeScript versions

This post is a solution for how to fix an angular application upgrade error “Error: The Angular Compiler requires TypeScript >=4.0.1 and 4.1.7 but 4.2.0 was found instead.”

This error occurs while migrating an application from Angular 9 to Angular 10 or Angular 10 to 11 versions.

This error occurred after my application was upgraded from Angular 10 to Angular 11 with the ng update command

What exactly does this error indicate? The Angular version expects a typescript version between 4.0.1 and 4.1.7, but it was updated with version 4.2.0.

The solution for this issue is

In the application, type the below command to know angular and typescript versions using this application

ng --version

It shows all of the versions of angular libraries, typescript, and their dependencies. My Application shows

  • Angular 11.0.5
  • typescript 4.2.7 version

The typescript was also installed as a devDependency.

As a result, the typescript must be uninstalled from the application.

Here is a command for uninstalling

npm uninstall -d typescript

The next step is to install the mandatory typescript version, which is 4.0.7.

npm install -d typescript@4.0.7

Next, run the ng --version command to list out the correct version 4.0.7.

Wrap up

It is an easy solution to fix an angular upgrade for the correct typescript version, Please make sure that read the version number and follow the above steps.