如何处理在Angular CLI中安装对等项依赖关系? [英] How do I deal with installing peer dependencies in Angular CLI?

查看:251
本文介绍了如何处理在Angular CLI中安装对等项依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试更新Angular CLI和NPM时,我发现自己陷入了几乎无休止的错误循环.每次更新时,都会遇到WARN消息,告诉我安装对等依赖项(请参阅下文),但是每次安装依赖项时,都会遇到更多的WARN消息.有没有更好的方法来处理这种情况,或者它是否需要花费数小时?

I've found myself in an almost endless cycle of errors when trying to update my Angular CLI and NPM. Every time I update, I am met with WARN messages telling me to install peer dependencies (see below), but each time I install a dependency, I am met with more WARN messages. Is there a better way of handling this situation or does it seriously take hours?

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的新手.

I know I must be doing something wrong, but I'm new to Angular.

推荐答案

对等依赖性警告通常可以忽略.您唯一要采取的措施是完全失去对等依赖项,或者对等依赖项的版本高于您已安装的版本.

Peer dependency warnings, more often than not, can be ignored. The only time you will want to take action is if the peer dependency is missing entirely, or if the version of a peer dependency is higher than the version you have installed.

让我们以这个警告为例:

Let's take this warning as an example:

npm WARN @ angular/animations @ 5.2.1需要一个 @ angular/core @ 5.2.1,但未安装.您必须安装对等 自己依赖.

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.

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

With Angular, you would like the versions you are using to be consistent across all packages. If there are any incompatible versions, change the versions in your package.json, and run npm install so they are all synced up. I tend to keep my versions for Angular at the latest version, but you will need to make sure your versions are consistent for whatever version of Angular you require (which may not be the most recent).

在这种情况下:

npm WARN ngx-carousel@1.3.5需要一个@ angular/core @ ^ 2.4.0的对等项|| ^ 4.0.0,但未安装.您必须安装对等依赖项 你自己.

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.

如果使用的Angular版本高于4.0.0,则可能没有任何问题.然后,与此无关.如果您使用的是2.4.0以下的Angular版本,则需要升级您的版本.更新 package.json ,然后运行npm install或运行npm install以获取所需的特定版本.像这样:

If you are working with a version of Angular that is higher than 4.0.0, then you will likely have no issues. Nothing to do about this one then. If you are using an Angular version under 2.4.0, then you need to bring your version up. Update the package.json, and run npm install, or run npm install for the specific version you need. Like this:

npm install @angular/core@5.2.3 --save

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

You can leave out the --save if you are running npm 5.0.0 or higher, that version saves the package in the dependencies section of the package.json automatically.

在这种情况下:

npm警告可选的跳过选择性依赖:fsevents@1.1.3 (node_modules \ fsevents):npm警告未跳过跳过可选依赖项: fsevents@1.1.3不受支持的平台:想要 {"os":"darwin","arch":"any"}(当前:{"os":"win32","arch":"x64"})

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.此警告可以忽略.

You are running Windows, and fsevent requires OSX. This warning can be ignored.

希望这对您有所帮助,并在学习Angular方面很有趣!

Hope this helps, and have fun learning Angular!

这篇关于如何处理在Angular CLI中安装对等项依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆