gpt4 book ai didi

angular - 我如何处理在 Angular CLI 中安装对等依赖项?

转载 作者:太空狗 更新时间:2023-10-29 16:46:35 31 4
gpt4 key购买 nike

在尝试更新我的 Angular CLI 和 NPM 时,我发现自己陷入了几乎无穷无尽的错误循环中。每次我更新时,我都会收到警告消息,告诉我安装对等依赖项(见下文),但每次我安装依赖项时,我都会收到更多警告消息。有没有更好的方法来处理这种情况,或者它真的需要几个小时吗?

npm WARN @angular/animations@5.2.1 requires a peer of @angular/core@5.2.1 
but none is installed. You must install peer dependencies yourself.
npm WARN @angular/compiler-cli@5.1.0 requires a peer of typescript@>=2.4.2
<2.6 but none is installed. You must install peer dependencies yourself.
npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-beta.6 requires a peer of
@angular/core@^4.0.3 but none is installed. You must install peer
dependencies yourself.
npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-beta.6 requires a peer of
@angular/common@^4.0.3 but none is installed. You must install peer
dependencies yourself.
npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-beta.6 requires a peer of
@angular/forms@^4.0.3 but none is installed. You must install peer
dependencies yourself.
npm WARN @schematics/angular@0.1.17 requires a peer of @angular-
devkit/core@0.0.29 but none is installed. You must install peer dependencies
yourself.
npm WARN @schematics/angular@0.1.17 requires a peer of @angular-
devkit/schematics@0.0.52 but none is installed. You must install peer
dependencies yourself.
npm WARN @schematics/schematics@0.0.11 requires a peer of @angular-
devkit/core@0.0.22 but none is installed. You must install peer dependencies
yourself.
npm WARN angular2-notifications@0.7.4 requires a peer of
@angular/core@^4.0.1 but none is installed. You must install peer
dependencies yourself.
npm WARN angular2-notifications@0.7.4 requires a peer of
@angular/common@^4.0.1 but none is installed. You must install peer
dependencies yourself.
npm WARN angular2-notifications@0.7.4 requires a peer of @angular/platform-
browser@^4.0.0 but none is installed. You must install peer dependencies
yourself.
npm WARN angular2-notifications@0.7.4 requires a peer of
@angular/animations@^4.0.1 but none is installed. You must install peer
dependencies yourself.
npm WARN bootstrap@4.0.0-beta.2 requires a peer of jquery@1.9.1 - 3 but none
is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.0.0-beta.2 requires a peer of popper.js@^1.12.3 but
none is installed. You must install peer dependencies yourself.
npm WARN ng2-toasty@4.0.3 requires a peer of @angular/core@^2.4.7 || ^4.0.0
but none is installed. You must install peer dependencies yourself.
npm WARN ngx-carousel@1.3.5 requires a peer of @angular/core@^2.4.0 ||
^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-carousel@1.3.5 requires a peer of @angular/common@^2.4.0 ||
^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsickle@0.25.5 requires a peer of typescript@>=2.4.2 <2.6 but none
is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3
(node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"})

我知道我一定做错了什么,但我是 Angular 的新手。

最佳答案

对等依赖警告通常可以忽略。只有当对等依赖项完全丢失,或者对等依赖项的版本高于您安装的版本时,您才会想要采取行动。

让我们以这个警告为例:

npm WARN @angular/animations@5.2.1 requires a peer of@angular/core@5.2.1 but none is installed. You must install peerdependencies yourself.

对于 Angular,您希望所使用的版本在所有包中保持一致。如果有任何不兼容的版本,请更改 package.json 中的版本,然后运行 ​​npm install 以便它们全部同步。我倾向于将我的 Angular 版本保持在最新版本,但您需要确保您的版本与您需要的任何 Angular 版本一致(可能不是最新版本)。

在这样的情况下:

npm WARN ngx-carousel@1.3.5 requires a peer of @angular/core@^2.4.0 ||^4.0.0 but none is installed. You must install peer dependenciesyourself.

如果您使用的 Angular 版本高于 4.0.0,那么您可能不会遇到任何问题。那就没什么可做的了。如果您使用的是 2.4.0 以下的 Angular 版本,则需要升级您的版本。更新 package.json,然后运行 ​​npm install,或者为您需要的特定版本运行 npm install。像这样:

npm install @angular/core@5.2.3 --save

如果您运行的是 npm 5.0.0 或更高版本,则可以省略 --save,该版本会将包保存在 package.json 的依赖项部分自动。

在这种情况下:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3(node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:Unsupported platform for fsevents@1.1.3: wanted{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

您运行的是 Windows,fsevent 需要 OSX。可以忽略此警告。

关于angular - 我如何处理在 Angular CLI 中安装对等依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48626005/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com