1

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?

Michael Sorens
  • 35,361
  • 26
  • 116
  • 172

1 Answers1

2

@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.

nash11
  • 8,220
  • 3
  • 19
  • 55
  • I suppose the error ("incompatible peer dependency") was a valid message, but it was not pointing me to the correct issue, so thank you! It's funny--some time ago my team had already moved from `@angular/http` to `@angular/common/http`, per the Angular instructions -- but the actual entry in package.json had not been removed! So that was all I needed... I believe I had tried upgrading typescript, but if I recall it needs to be updated with Angular. For now I will just remove `ngrx-tslint-oftype` then reinstall it after doing the Angular upgrade. – Michael Sorens Jul 08 '19 at 01:51
  • I can only say - same here :) Thanks! – itradoRD Jan 26 '23 at 14:12