Angular 从 6 更新到 8 期间令人费解的不兼容对等依赖性
Puzzling incompatible peer dependency during Angular update from 6 to 8
按照 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")
所以我有两个问题:
- 对于 ngrx-tslint-oftype,我研究了覆盖包对打字稿版本的依赖的方法,但到目前为止我发现的——主要是
npm shrinkwrap
——似乎有问题。
- 为什么@angular/http 仍然是一个投诉,我该如何解决?
请注意,我也尝试了 ng update --all
,但这给了我一些与其他软件包不兼容的问题,与 Angular 升级无关。
犹豫要不要加一个--force
;更愿意能够解决问题,所以这不是必需的。建议?
@angular/http
已被 Angular 弃用,不再使用(参见 here). You can make use of @angular/common/http
instead (See docs)。您将需要使用 HttpClientModule
中的 HttpClient
class
app.module.ts
import { HttpClientModule } from '@angular/common/http';
@NgModule({
imports: [
BrowserModule,
HttpClientModule
],
...
随时随地使用
import { HttpClient } from '@angular/common/http';
class MyService() {
constructor(http: HttpClient) { }
...
至于ngrx-tslint-oftype
的问题。尝试将您的打字稿版本升级到 3。
按照 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")
所以我有两个问题:
- 对于 ngrx-tslint-oftype,我研究了覆盖包对打字稿版本的依赖的方法,但到目前为止我发现的——主要是
npm shrinkwrap
——似乎有问题。 - 为什么@angular/http 仍然是一个投诉,我该如何解决?
请注意,我也尝试了 ng update --all
,但这给了我一些与其他软件包不兼容的问题,与 Angular 升级无关。
犹豫要不要加一个--force
;更愿意能够解决问题,所以这不是必需的。建议?
@angular/http
已被 Angular 弃用,不再使用(参见 here). You can make use of @angular/common/http
instead (See docs)。您将需要使用 HttpClientModule
HttpClient
class
app.module.ts
import { HttpClientModule } from '@angular/common/http';
@NgModule({
imports: [
BrowserModule,
HttpClientModule
],
...
随时随地使用
import { HttpClient } from '@angular/common/http';
class MyService() {
constructor(http: HttpClient) { }
...
至于ngrx-tslint-oftype
的问题。尝试将您的打字稿版本升级到 3。