Angular-cli: The Angular Compiler requires TypeScript >=2.7.2 and <2.10.0 but 3.0.1 was found instead.

Created on 13 Aug 2018  路  19Comments  路  Source: angular/angular-cli

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[+] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior


@angular/[email protected] requires typescript@'>=2.7.2 <2.10' but 3.0.1 was found instead.
Using this version can result in undefined behavior and difficult to debug problems.

Expected behavior


The compiler cli should use a newer version of typescript.

Minimal reproduction of the problem with instructions


Run
ng new MyProject
cd MyProject
npm i --save-dev typescript@latest
ng serve --open

What is the motivation/use case for changing the behavior?


The tools should use the current stable versions of other tools and not be making one or more steps back.

Environment

"@angular/cli": "~6.1.3",
"@angular/compiler-cli": "^6.1.2",
"@angular/language-service": "^6.1.2",
"@ngrx/schematics": "^6.1.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~10.5.8",
"codelyzer": "~4.4.3",
"jasmine-core": "~3.2.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^1.2.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.1",
"tslint": "~5.11.0",
"tslint-eslint-rules": "^5.3.1",
"typescript": "~3.0.1"


Angular version: 6.1.2

Browser:
Build problem

For Tooling issues:

  • Node version: 8.11.2
  • Platform: Win 10 (x64)

Most helpful comment

Hello,
I solve this problem like this.
npm install typescript@">=2.7.2 <2.10.0"
Unfortunately, you must run this command after each npm update.

All 19 comments

Similar happens if ng update @angular/cli is used. Typescript is updated to latest version (3.0.1) but the updater process will complain that typescript as a peer dependency should be lower version.

It's a "feature", not a bug. WTF: https://github.com/angular/angular-cli/issues/11138#issuecomment-395494996

@trollkotze Why would ng update upgrade typescript to the latest version, if the cli/compiler itself is not yet compatible with it? Seems so odd...

Yes that's what I meant to convey. It's weird.
Anyway, simply downgrading to typescript 2.9 again after that silly update solves it for now.

@angular/compiler-cli support for TypeScript 3 will land in Angular 7

Downgrading to typescript 2.9.2 (npm install [email protected]) and re-running ng update --all still yields the error (twice):
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.1.3"

Verified that version 2.9.2 of typescript was in node_modules.

Hello,
I solve this problem like this.
npm install typescript@">=2.7.2 <2.10.0"
Unfortunately, you must run this command after each npm update.

After update to Angular 7 (check your angular version with ng --version), I was still getting the error. What solved it for me after update, add the following line to your tsconfig.json:
"angularCompilerOptions": { "enableIvy": true }

After update to Angular 7 (check your angular version with ng --version), I was still getting the error. What solved it for me after update, add the following line to your tsconfig.json:
"angularCompilerOptions": { "enableIvy": true }

That's some trolling comment you just added right?

I was lead here as I worked through trying to get Angular to work locally. What worked for me was @emircanok 's solution of running npm install typescript@">=2.7.2 <2.10.0" but I ran mine with a --save flag.

My build works now. My version is the following:
Angular CLI: 7.3.1
Node: 8.11.1
OS: win32 x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 7.3.1
@angular/cli 7.3.1
@ngtools/webpack 6.0.8
@schematics/angular 7.3.1
@schematics/update 0.13.1
rxjs 6.0.0
typescript 2.9.2
webpack 4.8.3

Is there a way to avoid downgrade?
I get ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.3.0 but 3.4.5 was found instead.

@sotiris-rafail
There might be ways to isolate scopes: https://stackoverflow.com/questions/53578372/error-in-the-angular-compiler-requires-typescript-3-1-1-and-3-2-0-but-3-2-1-w

Using @emircanok 's version:
npm install typescript@" >=3.1.1 and <3.3.0" should work too

Same problem from Angular 7 to Angular 8, running ng update @angular/cli @angular/core

ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.1 was found instead.

Seems this fixed that specific build error:

npm install typescript@">=3.4.0 <3.5.0"

After update to Angular 7 (check your angular version with ng --version), I was still getting the error. What solved it for me after update, add the following line to your tsconfig.json:
"angularCompilerOptions": { "enableIvy": true }

This is work for me too.

I got same issue
Update Angular 6 to Angular 8, running ng update @angular/cli @angular/core
ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.2 was found instead.
then I tried

npm install typescript@">=3.4.0 <3.5.2"

still same error.

when I run ng build --prod

ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.1 was found instead.

Any idea?

npm install typescript@">=3.4.0 <3.5.0" --save-dev --save-exact worked for me perfectly just now.

sure.
npm install typescript@">=3.4.0 <3.5.0" --save-dev --save-exact works for me as well.

Still get

ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.1 was found instead.
When I do build.

ng build --prod

My ng version is:

Angular CLI: 8.1.1
Node: 10.16.0
OS: win32 x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.800.3
@angular-devkit/build-angular 0.800.3
@angular-devkit/build-optimizer 0.800.3
@angular-devkit/build-webpack 0.800.3
@angular-devkit/core 8.0.3
@angular-devkit/schematics 8.1.1
@angular/cdk 8.0.1
@angular/cli 8.1.1
@angular/flex-layout 8.0.0-beta.26
@angular/http 7.2.15
@angular/material 8.0.1
@ngtools/webpack 8.0.3
@schematics/angular 8.1.1
@schematics/update 0.801.1
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0

any idea?

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hareeshav picture hareeshav  路  3Comments

sysmat picture sysmat  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments