当我试图更新我的角度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"})我知道我一定做错了什么,但我对棱角并不熟悉。
发布于 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。如下所示:
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。可以忽略此警告。
希望这有帮助,并有乐趣学习角!
发布于 2019-02-22 01:28:51
在更新依赖项时,可以使用带有角cli的-force标志来忽略对等依赖项警告。
ng update @angular/cli @angular/core --force有关选项的完整列表,请查看docs:https://angular.io/cli/update
发布于 2021-07-14 07:17:19
更新您的角度(全局):
更新“角/cli”角/核心
npm uninstall -g @angular/clinpm install -g @angular/cli
之后,如果您想使用旧的角度项目(局部):
npm list进行测试,并获得以下错误:npm错误!同伴失踪:我的依赖人,某些成分所要求的
这意味着你必须更新你的项目:
npm list所需的所有依赖项。
npm install mydependencie
https://stackoverflow.com/questions/48626005
复制相似问题