Michael Sorens
Michael Sorens

Reputation: 36688

Puzzling incompatible peer dependency during Angular update from 6 to 8

Following the Angular update guide (https://update.angular.io/) I started with

$ ng update @angular/cli @angular/core

But that yielded this list of some incompatibilities:

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 "8.1.0").
Package "@ngrx/router-store" has an incompatible peer dependency to "@angular/router" (requires "^6.0.0" (extended), would install "8.1.0").
Package "ngrx-tslint-oftype" has an incompatible peer dependency to "typescript" (requires "^2.8.3", would install "3.4.5").
Package "@angular/http" has an incompatible peer dependency to "@angular/platform-browser" (requires "6.1.3" (extended), would install "8.1.0").
Package "@angular/material" has an incompatible peer dependency to "@angular/core" (requires ">=6.0.0-beta.0 <7.0.0" (extended), would install "8.1.0").
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 "8.1.0").
Package "@angular/material" has an incompatible peer dependency to "@angular/core" (requires ">=6.0.0-beta.0 <7.0.0" (extended), would install "8.1.0").

I updated codelyzer to knock that off the list. I then figured that I could change the command to remove a few more:

$ ng update @angular/cli @angular/core @ngrx/store @angular/material @angular/http

That left me with this puzzling result, puzzling because one of the two @angular/http incompatibilities is still present!

Package "ngrx-tslint-oftype" has an incompatible peer dependency to "typescript" (requires "^2.8.3", would install "3.4.5").
Package "@angular/http" has an incompatible peer dependency to "@angular/core" (requires "7.2.15", would install "8.1.0")

So I have two issues:

  1. For ngrx-tslint-oftype, I looked into ways to override the package's dependency on the typescript version, but what I found so far--mainly npm shrinkwrap--seemed to have issues.
  2. Why is @angular/http still a complaint and how do I fix it?

Note that I also tried ng update --all but that gave me some incompatibilities with other packages, not relevant to the Angular upgrade.

I am hesitant to add a --force; would much prefer to be able to fix things so that is not a necessity. Suggestions?

Upvotes: 1

Views: 1791

Answers (1)

nash11
nash11

Reputation: 8650

@angular/http has been deprecated by Angular and is no longer in use (See here). You can make use of @angular/common/http instead (See docs). You will need to use the HttpClient class from the HttpClientModule

app.module.ts

import { HttpClientModule } from '@angular/common/http';

@NgModule({
 imports: [
   BrowserModule,
   HttpClientModule
 ],
...

Wherever you want to use it

import { HttpClient } from '@angular/common/http';

class MyService() {
    constructor(http: HttpClient) { }
...

As for the issue with ngrx-tslint-oftype. Try upgrading your typescript version to 3.

Upvotes: 2

Related Questions