首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何处理如何在角CLI中安装对等依赖项?

如何处理如何在角CLI中安装对等依赖项?
EN

Stack Overflow用户
提问于 2018-02-05 15:32:54
回答 5查看 175.4K关注 0票数 92

当我试图更新我的角度CLI和NPM时,我发现自己处于一个几乎无休止的错误循环中。每次更新时,都会收到警告消息,告诉我要安装对等依赖项(见下文),但每次安装依赖项时,都会遇到更多的警告消息。是否有更好的方法来处理这种情况,还是真的要花上几个小时?

代码语言:javascript
复制
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"})

我知道我一定做错了什么,但我对棱角并不熟悉。

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2018-02-05 16:25:01

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

让我们以这个警告为例:

npm警告@角/动画@5.2.1需要一个“角/核心”的对等点5.2.1,但没有安装。您必须自己安装对等依赖项。

与棱角,您会希望您使用的版本是一致的所有包。如果有任何不兼容的版本,请更改package.json中的版本,并运行npm install,以便它们都同步起来。我倾向于在最新版本中保留“角”的版本,但您需要确保您的版本对于所需的任何版本都是一致的(这可能不是最近的版本)。

在这种情况下:

npm警告ngx-carousel@1.3.5需要一个“角/核心”的对等点:^2.4.00x\x ^4.0.0,但没有安装。您必须自己安装对等依赖项。

如果您使用的角度版本高于4.0.0,那么您可能没有任何问题。对这件事没什么可做的。如果您使用的是2.4.0以下的棱角版本,那么您需要将您的版本提升。更新package.json,并运行npm install,或针对所需的特定版本运行npm install。如下所示:

代码语言:javascript
复制
npm install @angular/core@5.2.3 --save

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

在这种情况下:

npm警告可选跳过可选依赖项: fsevents@1.1.3 (node_modules\fsevents):npm警告不跳过可选依赖:不支持fsevents@1.1.3的平台:希望{“os”:“达尔文”,“arch”:“任意”}(当前:{"os":"win32","arch":"x64"})

您正在运行Windows,而fsevent需要OSX。可以忽略此警告。

希望这有帮助,并有乐趣学习角!

票数 94
EN

Stack Overflow用户

发布于 2019-02-22 01:28:51

在更新依赖项时,可以使用带有角cli的-force标志来忽略对等依赖项警告。

代码语言:javascript
复制
ng update @angular/cli @angular/core --force

有关选项的完整列表,请查看docs:https://angular.io/cli/update

票数 5
EN

Stack Overflow用户

发布于 2021-07-14 07:17:19

更新您的角度(全局):

  • 通过以下方式更新:

更新“角/cli”角/核心

  • 或移除角并重新安装:

npm uninstall -g @angular/cli npm install -g @angular/cli

之后,如果您想使用旧的角度项目(局部):

  • 如果某些依赖项已更改,请使用npm list进行测试,并获得以下错误:

npm错误!同伴失踪:我的依赖人,某些成分所要求的

这意味着你必须更新你的项目:

  • 然后您就可以创建一个新项目,粘贴您的代码并重新安装所有的依赖项。
  • 或安装npm list所需的所有依赖项。

npm install mydependencie

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48626005

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档