angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng upgrade: incompatible peer dependency error prevents from auto-updating

Open juristr opened this issue 8 years ago • 46 comments

Versions

Angular CLI: 6.0.1
Node: 9.11.1
OS: darwin x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.1
@angular-devkit/build-angular     0.6.1
@angular-devkit/build-optimizer   0.6.1
@angular-devkit/core              0.6.1
@angular-devkit/schematics        0.6.1
@angular/cli                      6.0.1
@ngtools/webpack                  6.0.1
@schematics/angular               0.6.1
@schematics/update                0.6.1
rxjs                              5.5.10
typescript                        2.5.3
webpack                           4.6.0


macOS 10.11.6

Repro steps

  • Clone the upgrade branch of repo https://github.com/juristr/ng-upgrade-test
  • yarn install (or npm install => I used yarn)
  • Try upgrading the Angular dependencies, using for instance ng update @angular/core. I already performed the @angular/cli upgrade command which adjusts the angular.json etc.

Observed behavior

<!-- Normally this includes a stack trace and some more information. -->

I get the following output

❯ ng update @angular/core
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.5.3")
Incompatible peer dependencies found. See above.

Desired behavior

It should automatically update the Angular dependencies as well as RxJS and TypeScript (as described in the update.angular.io guide).

Mention any other details that might be useful (optional)

juristr avatar May 15 '18 21:05 juristr

@clydin Hi, I was chatting about this in the Angular Slack with @filipesilva and he told me to open the issue here. Let me know if you need more info. Thanks a lot 👍

juristr avatar May 15 '18 21:05 juristr

I'm running into a similar issue when trying to update NgRx.

If I have all the @ngrx libraries installed and I run ng update @ngrx/store --next I get

Package "@ngrx/schematics" has a missing peer dependency of "@angular-devkit/core" @ "^0.6.0".

If I run yarn list @angular-devkit/core, I see

@angular-devkit/[email protected]

brandonroberts avatar May 16 '18 17:05 brandonroberts

Not sure if it's the same thing, but I'm getting errors like:

Package "bootstrap" has a missing peer dependency of "jquery" @ "1.9.1 - 3".

I'm using the bootstrap SCSS framework but have no intentions of ever including jQuery ofc. I dunno if this is a problem with bootstrap itself that it has jquery as a peerDep or if the problem is that CLI throws for peer dep WARN.

Is it perhaps possible to just force the ng update --all?

intellix avatar May 19 '18 09:05 intellix

I have the same issue, but instead run ng update @angular/compiler-cli successfully without error.

Teamop avatar May 21 '18 09:05 Teamop

I'm running into this issue as well, seems the updater is trying to install [email protected] but @angular/compiler-cli has a peer dependency of typescript@">=2.7.2 <2.8".

getabetterpic avatar May 22 '18 11:05 getabetterpic

When I ran "ng update @angular/core" got the following errors and cannot upgrade to angular 6: Package "angular2-resizable" has an incompatible peer dependency to "@angular/core" (requires ">=3.0.0-rc.0 <4.0.0||>=2.0.0 <3.0.0", would install "6.0.2"). Package "codelyzer" has an incompatible peer dependency to "@angular/compiler" (requires ">=5.0.0-rc.0 <6.0.0||>=2.3.1 <3.0.0||>=4.0.0-beta <5.0.0", would install "6.0.2").

sachinpachori avatar May 22 '18 13:05 sachinpachori

Just so its noted, the workaround is to use the --force flag when running ng update [package] to override the dependency issues. This will upgrade the packages anyway and you can verify your app with the updated dependencies. If that third party dependency still needs to be updated because of breaking changes, then that package will need to be updated.

ng update @ngrx/store --next --force

brandonroberts avatar May 22 '18 14:05 brandonroberts

@sachinpachori Those are actually legitimate errors. The project has a dependency (angular2-resizable) that does not support Angular 6. As @brandonroberts mentions, the --force flag can be used (with caution) to update while ignoring those issues. And similar with codelyzer; however, since codelyzer is part of the default project this could potentially (and in the future) be automatically updated (depending on the pinning strategy) with a CLI update.

clydin avatar May 22 '18 15:05 clydin

@brandonroberts @clydin thank you that solved my issue.

sachinpachori avatar May 23 '18 22:05 sachinpachori

I could have faced incompatible peer dependency issues when i ran the command ng update @angular/core to update the core library of the existing angular project.

Issues

Package "@angular/cdk" has an incompatible peer dependency to "@angular/common" (requires ">=5.0.0-rc.0 <6.0.0||>=4.0.0 <5.0.0", would install "6.0.0"). Package "codelyzer" has an incompatible peer dependency to "@angular/core" (requires ">=5.0.0-rc.0 <6.0.0||>=2.3.1 <3.0.0||>=4.0.0-beta <5.0.0", would install "6.0.0"). Package "codelyzer" has an incompatible peer dependency to "@angular/compiler" (requires ">=5.0.0-rc.0 <6.0.0||>=2.3.1 <3.0.0||>=4.0.0-beta <5.0.0", would install "6.0.0").

in second time i used the following command to update the core library ng update @angulsar/core --next but still there an issue.

issue had fix when i use the following command with --force flag, ng update @angular/core --next --force

now, my project library has been updated from version 4 to 6. Well done :)

Good Luck !!!

devssharma avatar Jun 03 '18 09:06 devssharma

ng update @angular/core --next --force works for me

HarryWang74 avatar Jun 04 '18 02:06 HarryWang74

I'm doing a fresh install of my npm modules, and running into this issue:

$ npm install -g @ngrx/schematics@latest
npm WARN @ngrx/[email protected] requires a peer of @angular-devkit/core@^0.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngrx/[email protected] requires a peer of @angular-devkit/schematics@^0.6.0 but none is installed. You must install peer dependencies yourself.

But angular-devkit/[email protected] is installed. Is using --force still the recommended workaround?

Sharondio avatar Jun 13 '18 02:06 Sharondio

@Sharondio You're installing @ngrx/schematics@latest globally. If that is intentional then the peer dependencies of the package would also need to be installed globally.

clydin avatar Jun 13 '18 15:06 clydin

@clydin They are installed globally. Still getting error.

Sharondio avatar Jun 13 '18 16:06 Sharondio

If npm ls -g --depth=0 doesn't show the warnings then everything should be fine. Please note that this is actually an npm issue (and possible a defect) and not a CLI issue.

clydin avatar Jun 13 '18 16:06 clydin

So I figured out that ng update --all doesn't work as expected, so you better upgrade everything in order:

yarn global @angular/cli
ng update @angular/cli
yarn upgrade tsickle
ng update @angular/core
ng update @angular/material
ng update rxjs
yarn add @angular-devkit/schematics@^0.6.0 --dev
ng update @ngrx/store
ng update @nrwl/nx

Note that I had to update some dependencies because @angular/core installs typescript 2.9.2 and the version I had of tsickle didn't supported it:

Package "tsickle" has an incompatible peer dependency to "typescript" (requires ">=2.4.2 <2.9", would install "2.9.2").

and also @ngrx/store had a missing dependency:

Package "@ngrx/schematics" has a missing peer dependency of "@angular-devkit/schematics" @ "^0.6.0".

Thanks for the great work!

matheo avatar Jul 27 '18 03:07 matheo

I just ran

ng update --all --next --force

and the output was (ok):

Package "codelyzer" has an incompatible peer dependency to "@angular/compiler" (requires ">=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0", would install "6.1.0-rc.3")
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.1.0-dev.20180802")
Package "@angular/cdk" has an incompatible peer dependency to "@angular/common" (requires ">=6.0.0-beta.0 <7.0.0" (extended), would install "6.1.0-rc.3").
Package "codelyzer" has an incompatible peer dependency to "@angular/compiler" (requires ">=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0" (extended), would install "6.1.0-rc.3").
Package "codelyzer" has an incompatible peer dependency to "@angular/core" (requires ">=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0" (extended), would install "6.1.0-rc.3").
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.1.0-dev.20180802").
Updating package.json with dependency karma-jasmine-html-reporter @ "1.2.0" (was "0.2.2")...
Updating package.json with dependency jasmine-core @ "3.1.0" (was "2.99.1")...
Updating package.json with dependency codelyzer @ "4.4.2" (was "4.2.1")...
Updating package.json with dependency protractor @ "5.4.0" (was "5.3.2")...
Updating package.json with dependency ts-node @ "7.0.0" (was "5.0.1")...
Updating package.json with dependency @angular/animations @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/compiler-cli @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/language-service @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/http @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/platform-browser @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/common @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/compiler @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/forms @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/core @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/router @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "6.1.0-rc.3" (was "6.0.9")...
Updating package.json with dependency @types/node @ "10.5.5" (was "8.9.5")...
Updating package.json with dependency karma @ "2.0.5" (was "1.7.1")...
Updating package.json with dependency typescript @ "3.1.0-dev.20180802" (was "2.7.2")...
Updating package.json with dependency @angular-devkit/build-angular @ "0.8.0-beta.0" (was "0.6.8")...
UPDATE package.json (1662 bytes)
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
npm WARN deprecated [email protected]: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated [email protected]: This project is unmaintained
npm WARN deprecated [email protected]: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
npm WARN deprecated [email protected]: This project is unmaintained

> [email protected] install ...\node_modules\uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0

npm WARN rollback Rolling back [email protected] failed (this is probably harmless): EPERM: operation not permitted, lstat '...\node_modules\fsevents\node_modules'
npm WARN [email protected] requires a peer of typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of typescript@>=2.7.2 <2.10 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/[email protected] requires a peer of typescript@~2.4.0 || ~2.5.0 || ~2.6.0 || ~2.7.0 || ~2.8.0 || ~2.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.4.2 <2.9 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 120 packages from 165 contributors, removed 48 packages, updated 77 packages, moved 3 packages and audited 16744 packages in 47.871s
found 6 vulnerabilities (1 low, 5 moderate)
run `npm audit fix` to fix them, or `npm audit` for details

Newbie012 avatar Aug 02 '18 10:08 Newbie012

If anyone's still running into this error you could try running

npm i --save-dev [email protected] before running ng update @angular/core

instead of forcing ng update --next --force which ignores those warnings and installs beta packages.

prasanthlouis avatar Aug 31 '18 15:08 prasanthlouis

it gave me a successful serve but in browser I got this error

AppComponent.html:1 ERROR TypeError: (intermediate value).switchMap is not a function
    at new AngularFireAuth (auth.js:21)
    at _getAngularFireAuth (auth.module.js:6)
    at _callFactory (core.js:16720)
    at _createProviderInstance (core.js:16676)
    at resolveNgModuleDep (core.js:16636)
    at _createClass (core.js:16709)
    at _createProviderInstance (core.js:16673)
    at resolveNgModuleDep (core.js:16636)
    at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:17345)
    at resolveDep (core.js:17716) 

asmaa3107 avatar Sep 02 '18 02:09 asmaa3107

ng update @angular/cli@version --force it worked for me

leonardox12 avatar Sep 04 '18 15:09 leonardox12