Incompatible peer dependencies

I will go through some of incompatible peer dependency errors that I received during my upgrade process and the different strategies to resolve these errors. Note that I will start with simple cases and demonstrate the amount of research that may be required as the dependency you need may not be simply the latest released version of your package.

  • Package karma-jasmine-html-reporter has a missing peer dependency of "jasmine" @ "^3.0.0".

This is a simple error that is resolved by simply updating to the latest version of jasmine, as follows:

$ npm i -D jasmine
  • Package @angular/flex-layout has an incompatible peer dependency to "rxjs" (requires "^5.5.0", would install "6.1.0").

This error requires a bit of research and understanding of the ecosystem. As of Angular 6, we know that all libraries are version synced, so we need a 6.x version of this library. Let's discover the currently available versions with npm info:

$ npm info @angular/flex-layout
...
dist-tags:
latest: 5.0.0-beta.14 next: 6.0.0-beta.15

published a month ago by angular <[email protected]>

As of publishing, this library is still in beta and the latest version is at 5.0.0, so simply updating to the latest release of @angular/flex-layout won't work out. In this case, we need to install the @next version of the package, as follows:

$ npm i @angular/flex-layout@next
You will receive a bunch of dependency warnings showing that Angular 6 packages are needed. These errors will go away once we're done with our update.
  • Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.8.3").

Angular CLI depends on a specific version of Typescript. If you execute npm info typescript, the latest version of Typescript may be newer than what is required. In this case, it is 2.8.3, as reported in the preceding error message. The error message does signal to us what version is specifically required, if you look at the requires statement. The lower bound, 2.7.2, seems to be the correct version to install, so let's install that, as shown:

$ npm install -D [email protected]

In theory, all of our actions should have resolved all peer dependency issues. In reality, I have noted that these errors sometimes persist, when npx ng update --all is used, so we will continue the update by running individual update commands.

On non-macOS operating systems, you may persistently encounter an fsevents-related warning, such as npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected]. This is an optional package that is only leveraged on macOS. An easy way to avoid seeing this error is to run npm install --no-optional command.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.37.10