Angular-cli: Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.1.1 <3.2", would install "3.2.1")

Created on 29 Nov 2018  路  31Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions


Node Version: v8.11.4
npm Version: 6.4.1
ng Version:
Angular CLI: 7.0.4
Node: 8.11.4
OS: win32 x64
Angular: 7.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

              Package                           Version
              -----------------------------------------------------------
              @angular-devkit/architect         0.10.4
              @angular-devkit/build-angular     0.10.4
              @angular-devkit/build-optimizer   0.10.4
              @angular-devkit/build-webpack     0.10.4
              @angular-devkit/core              7.0.4
              @angular-devkit/schematics        7.0.4
              @angular/cli                      7.0.4
              @ngtools/webpack                  7.0.4
              @schematics/angular               7.0.4
              @schematics/update                0.10.4
              rxjs                              6.3.3
              typescript                        3.1.6
              webpack                           4.19.1

Repro steps

              ng update --all

The log given by the failure


Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.1.1 <3.2", would install "3.2.1")
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.1.1 <3.2", would install "3.2.1").
Incompatible peer dependencies found. See above.

Desired functionality

Mention any other details that might be useful

schematicupdate high ng update DX broken triage #1 bufix

Most helpful comment

@billfranklin Sorry, I mistook ng-update with https://www.npmjs.com/package/npm-check-updates.
Yes, this is a bug. ng-update should update typescript to latest supported version.
But I don't think it will be resolved soon: https://github.com/angular/angular-cli/issues/11138#issuecomment-395494996.

@dalu You can do:
ng update --all --force
and then
npm i [email protected] (or even better: npm i typescript@"<3.2")

All 31 comments

Hi @billfranklin
It's normal behavior.
Latest @angular/angular-cli:7.1.0 is shipped with typescript:3.1.6 and supports only patches: typescript < 3.2.
Newest typescript:3.2.1 increments minor version (typescript:3.1.6 in @angular/angular-cli:7.1.0) and should not have breaking changes but it's safer to limit typescript updates to patches.

See https://semver.org/~~
https://github.com/angular/angular-cli/issues/13095#issuecomment-443523984

Hi @billfranklin
It's normal behavior.
Latest @angular/angular-cli:7.1.0 is shipped with typescript:3.1.6 and supports only patches: typescript < 3.2.
Newest typescript:3.2.1 increments minor version (typescript:3.1.6 in @angular/angular-cli:7.1.0) and should not have breaking changes but it's safer to limit typescript updates to patches.

See https://semver.org/

It's normal behavior for ng update to throw errors? Seems like bad design to me...

This is the error generated while it is trying to update the compiler-cli...should be fixed to NOT try to install an incompatible dependency

@KrzysztofKarol This also makes it impossible to install "@angular/cli" with the latest version of "@angular/core". I don't see how that's normal behaviour. Surely the latest version of the CLI should be compatible with the latest version of the framework?

@billfranklin Sorry, I mistook ng-update with https://www.npmjs.com/package/npm-check-updates.
Yes, this is a bug. ng-update should update typescript to latest supported version.
But I don't think it will be resolved soon: https://github.com/angular/angular-cli/issues/11138#issuecomment-395494996.

@dalu You can do:
ng update --all --force
and then
npm i [email protected] (or even better: npm i typescript@"<3.2")

@angular/service-worker wrong peerDependency in 7.1.0 angular/angular#27233 is referencing back to this issue!

Will this be updated soon?

13123

same issue here

rakishii13, this is #13123
image

and references back here...

this has always been an issue, it's not even new.

Can't ng update just try to install the latest compatible version of TypeScript? Now I have to go through each package and check if it's compatible with Angular because it errors out right away.

I solved this issue via;

ng update --all --force

npm install typescript@">=3.1.1 <3.2"

Not sure if this will help anyone else, but I was running the following to no avail:
ng update --all --force
npm install typescript@">=3.1.1 <3.2"

I needed to add RUN npm install typescript@">=3.1.1 <3.2" to my Dockerfile just after it completed an npm install of my package.json. Not sure if anyone else needs this pointed out, but wanted to mention in case it helps anyone else. Cheers!

I tried updating via the documentation and I was getting an issue with the ng-http-loader package when I attempted to use the update command as documented (ng update @angular/core)

Package "ng-http-loader" has an incompatible peer dependency to "@angular/common" (requires "~7.0.0" (extended), would install "7.2.1").
Package "ng-http-loader" has an incompatible peer dependency to "@angular/core" (requires "~7.0.0" (extended), would install "7.2.1").

So I attempted to update it ng-http-loader by itself and this happened:


ng update ng-http-loader
    Updating package.json with dependency @angular/language-service @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/compiler-cli @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/animations @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/forms @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/core @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/http @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/compiler @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/common @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/platform-browser @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/router @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "7.2.1" (was "6.1.10")...
    Updating package.json with dependency ng-http-loader @ "5.0.0" (was "3.2.0")...
    Updating package.json with dependency typescript @ "3.2.4" (was "2.7.2")...
    Updating package.json with dependency zone.js @ "0.8.28" (was "0.8.27")...
UPDATE package.json (3402 bytes)

All of my packages updated to v7.2.1 related to Angular.

For what it's worth, I started out just trying:

ng update @angular/cli @angular/core

but that failed with the error in the title of this issue. Next, I tried just upgrading typescript first, then I found I was able update everything else. I found through trial and error that I had to use a specific version of typescript which is 3.1.6.

Here's what I did. I can't guarantee this was all that I did :) but I believe this is what worked:

npm i [email protected] --save-dev --save-exact

ng update @angular/cli

ng update --all --force

So I'm upgraded to angular 7 at least. Got a few compile errors now in my Typescript code which were not there previously but I'm assuming those are related to TS deprecations. I was upgrading from Angular 6.0 -> 7.

This just hit me again with typescript 3.3.4. Why have this automatic update which gets destroyed by the higher version of typescript?

Every time I go onng update this issue still apears. Even at angular-cli 7.3.6.
It's solved just with:
npm i [email protected]
just after ng update as this is the last typescript version accepted.

Another reproduction with some more details can be found here: https://github.com/angular/angular-cli/issues/14420#issue-443916012

I had the same problem upgrading from [email protected] to the latest 7.2.15 and had the error come up with [email protected] (well within the >= 3.1.1 < 3.3 requirement). The solution was to manually install the following:

npm i ajv@latest
npm i [email protected]
npm audit fix --force

Then my project compiled successfully with zero vulnerabilities or warnings showing up. I hope this helps others getting the same error message

EVERY
SINGLE
TIME

i really don't get this, what is the use of "ng update" when it is not really usable at all?
Why is something that updates angular that understands angular not be able to leave typescript alone or upgrade it to the latest supported version?

ng update --all --force
npm install [email protected] --save-exact (you don't even need this anymore with angular 8.2.0, it works with the latest [email protected])

That's my version of ng update.

ng update --all --force
~npm install [email protected] --save-exact~ (you don't even need this anymore with angular 8.2.0, it works with the latest [email protected])

That's my version of ng update.

This is not an option since versions always are bumping. E.g. now it states that @angular/core conflicts with latest zone.js version and tsickle conflicts with latest typescript version.

ng update definetly should take care of its own dependencies at least.

I was having trouble starting npm install.
[- ERROR in The Angular Compiler requires TypeScript> = 3.4.0 and <3.6.0 but 3.6.3 was found instead.]

  • The commands:
  • ng update --all --force
  • npm install typescript @ "> = 3.1 <3.6"
  • npm strat (success)

Thanks for the help.

package.json

{
"name": "my-project",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.6",
"@angular/common": "~8.2.6",
"@angular/compiler": "~8.2.6",
"@angular/core": "~8.2.6",
"@angular/forms": "~8.2.6",
"@angular/platform-browser": "~8.2.6",
"@angular/platform-browser-dynamic": "~8.2.6",
"@angular/router": "~8.2.6",
"core-js": "^3.2.1",
"rxjs": "~6.5.3",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.4",
"@angular/cli": "~8.3.4",
"@angular/compiler-cli": "~8.2.6",
"@angular/language-service": "~8.2.6",
"@types/jasmine": "~3.4.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~12.7.5",
"codelyzer": "~5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-node": "~8.3.0",
"tslint": "~5.20.0",
"typescript": "^3.5.3"
}
}

Very similar to what I have in my package.json file:

  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "update": "ng update --all --force && npm install [email protected] && npm install [email protected]"
  },

Saves me the headache of updating.

Very similar to what I have in my package.json file:

  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "update": "ng update --all --force && npm install [email protected] && npm install [email protected]"
  },

Saves me the headache of updating.

Thank you!
But isn't typescipt supposed to be in the dev dependencies?

Actually I have several projects. One of my projects couldn't solve.
So I copy all app models and components and paste it to the success project and then do some necessary steps.
npm install -g @angluar/cli
ng update --all --force
is works for me

@asalam345 this works for now, but not when a new TS version will come out. The CLI will just happily upgrade your packages to a version of TS that is incompatible with Angular.

@asalam345 this works for now, but not when a new TS version will come out. The CLI will just happily upgrade your packages to a version of TS that is incompatible with Angular.

then need to update all I think.

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