在从6升级到8的Angular更新过程中令人困惑的不兼容对等项依赖

时间:2019-07-07 05:46:05

标签: angular dependency-management

按照我开始的Angular更新指南(https://update.angular.io/

$ ng update @angular/cli @angular/core

但这产生了一些不兼容的清单:

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").

我更新了codelyzer,将其从列表中删除。 然后,我想到可以更改命令以删除更多内容:

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

这给我留下了令人困惑的结果,令人困惑,因为仍然存在两个@angular/http不兼容之一!

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")

所以我有两个问题:

  1. 对于ngrx-tslint-oftype,我研究了一些方法来改写程序包对打字稿版本的依赖性,但到目前为止,我发现的内容主要是npm shrinkwrap似乎有问题。
  2. 为什么@ angular / http仍然是投诉,我该如何解决?

请注意,我也尝试过ng update --all,但这使我与其他与Angular升级无关的软件包不兼容。

我不愿意添加--force;会更愿意能够解决问题,因此这不是必需的。有建议吗?

1 个答案:

答案 0 :(得分:1)

id | lat | lon | observed | error ----+-----+-----+----------+------- 1 | 1 | 1 | 11 | -1 2 | 2 | 2 | 25 | -5 3 | 3 | 3 | 32 | -2 已被Angular弃用,不再使用(请参见here)。您可以改用@angular/http(请参阅docs)。您将需要使用@angular/common/http

中的HttpClient

app.module.ts

HttpClientModule

您想使用它的任何地方

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

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

关于import { HttpClient } from '@angular/common/http'; class MyService() { constructor(http: HttpClient) { } ... 的问题。尝试将您的打字稿版本升级到3。