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

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

Yes

Yes, the previous version in which this bug was not present was: ....

Description

Having this issue trying to do an ng update on a pretty stock angular 7 application to angular 8:

ng update @angular/cli
Your global Angular CLI version (8.0.0) is greater than your local
version (7.3.8). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.1.1 <3.3", would install "3.4.5").
Incompatible peer dependencies found. See above.

package.json:

{
  "name": "sample-player",
  "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": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "videogular2": "^6.4.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.8",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
}

🔬 Minimal Reproduction

🔥 Exception or Error





🌍 Your Environment





About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 37 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Also, do we have to do a git commit after every update operation??

ng update @angular/core
Repository is not clean.  Please commit or stash any changes before updating.

Ran into this as well. The only way I could get angular to upgrade 8 (from 7) was to use npm install @angular/cli@8.0.0 --save-dev (opposed to ng update @angular/cli

once I did this, I ran into the issue @jtsom called out:

Repository is not clean. Please commit or stash any changes before updating.

Once I committed the changes and ran ng update --all, I get more warnings:

Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1")
                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=3.1 < 3.5", would install "3.5.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1").
Incompatible peer dependencies found. See above.

Hi, are you running ng update @angular/cli @angular/core? You need to update both the CLI and the framework at the same time.

I had the same errors. Here’s what worked for me:

I ran the following to update the global version of the Angular CLI: npm i -g @angular/cli@8.0.0

Then I ran the following to update my angular project: ng update --all --force

Note: It’s important to have a clean, up-to-date repo before running trying to update

i also meet this error. first,i run

ng update @angular/core

and them

ng update @angular/cli

i don’t run

ng update rxjs

now i have upgraded to angular8 and every thing sees ok. i hope it is helpful

run this command git status --porcelain and add files and directories to ignore file or commit

The problem is, usually Angular follows new Typescript releases from a few months behind and once there is a new Typescript version, ng update --all becomes unusable. The only solutions that I can think are adding an option to:

  • Add an option to skip updating incompatible dependencies:
ng update --all --skipIncompatible
  • Add an option to exclude some dependencies:
ng update --all --except typescript

Am updating the angular 7 to 8, after updating the ng update @angular/cli @angular/core command updated successfully, but after updating the material through ng update @angular/material entered, then i got the error. Repository is not clean. Please commit or stash any changes before updating.

i also meet this error. first,i run

ng update @angular/core

and them

ng update @angular/cil

i don’t run

ng update rxjs

now i have upgraded to angular8 and every thing sees ok. i hope it is helpful

Thanks, seems to be working! Btw, you made a little spelling mistake in your ng update @angular/cil command, it should be ng update @angular/cli

@mswilson4040 same problem, Finally I use npm to update angular, like this:

npm install @angular/cli@latest @angular-devkit/build-angular@latest  --save-dev

npm install @angular/{common,compiler,compiler-cli,core,forms,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@3.4 --save

After update, you should manually add parameter to ViewChild or ContentChild

Seems like ng update is just getting more finicky and fragile with every release.

If ng update --all doesn’t work, then it should be removed.

Or at the very least, this message should be changed:

 We analyzed your package.json, there are some packages to update:
    
      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cli                       7.3.9 -> 8.0.1           ng update @angular/cli
      @angular/core                      7.2.15 -> 8.0.0          ng update @angular/core
    
    
    There might be additional packages that are outdated.
    Run "ng update --all" to try to update all at the same time.

run this command git status --porcelain and add files and directories to ignore file or commit

Before you use ng update, you should commit or stash all files