How to fix an error The Angular Compiler requires TypeScript versions


This post is an 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 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.

Solution for this issue is

In the application, type 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

Typescript was also installed as a devDependency.

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

Here is an command for uninstall

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 ng --version command to list out correct version 4.0.7.

Wrap up

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

Similar Posts