使用纱线安装软件包时,“具有未满足的对等依赖性"是什么意思? [英] What does 'has unmet peer dependency' mean when installing a package with yarn?

查看:38
本文介绍了使用纱线安装软件包时,“具有未满足的对等依赖性"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我全新安装了 yarn(通过 npm install yarn -g)并尝试使用

I have a fresh install of yarn (via npm install yarn -g) and tried to install a few packages with

yarn add vue-loader babel-loader style-loader css-loader file-loader webpack

我在安装过程中收到了一些警告,例如

I got a few warnings during the install, such as

warning "vue-loader@13.3.0" has unmet peer dependency "vue-template-compiler@^2.0.0".

这到底是什么意思,特别是:为什么 yarn 不自行安装这些依赖项?(如果需要的话)

What does this exactly mean, and specifically: why doesn't yarn install these dependencies on its own? (if they are needed)

一个姐妹问题(关于npm) 在同一主题上产生了一些答案,建议 i) 更新 npm ii) 删除 node_modules,因为 npm 中存在错误 关于处理依赖项.

A sister question (about npm) on the same subject yields a few answers which suggest to i) update npm ii) remove node_modules as there is a bug in npm about handling dependencies.

yarn 中此类警告的状态是什么?这真的是警告吗(= 我可以丢弃的东西)? 我不能丢弃它们(webpack 构建失败)并且必须手动安装它们.同时,安装了相当多的依赖项,所以我不明白为什么遗漏了一些(虽然它们可以手动安装)

What is the status for such warnings in yarn? Is this really a warning (= something I can discard)? I cannot discard them (the webpack build fails) and have to manually install them. At the same time, quite a few dependencies were installed so I do not understand why a few were missed (while they are installable manually)

推荐答案

什么是对等依赖

这里是一些关于依赖类型的有用读物,这里是关于对等依赖的信息,但总结一下:

What is a peer dependency

Here is some useful reading on dependency types, and here is info on peer dependencies, but to summarize:

依赖项:您的项目需要运行的库/包.
对等依赖:用于表示您的项目将连接到的库/包.

Dependency: A library/package you project needs to run.
Peer dependency: Used to indicate a library/package your project will hook in to.

vue-loader 包对 vue-template-compiler 有对等依赖 - vue-loader 充当 vue-template-compiler

The package vue-loader has a peer dependency on vue-template-compiler - vue-loader acts as a plugin for vue-template-compiler

对等依赖项会自动安装直到 npm@3(其中纱线跟了进去).由于经常出现令人困惑的行为,这已停止.例如,安装另一个具有冲突要求的插件会导致错误.

Peer dependencies were automatically installed up till npm@3 (which yarn has followed in). This was stopped due to frequently confusing behavior. For example, installing another plugin with a conflicting requirement would result in an error.

我们还将更改 npm@3 中 peerDependencies 的行为.我们将不再自动下载对等依赖项.相反,如果尚未安装对等依赖项,我们会警告您.这需要您自己手动解决 peerDependency 冲突,但从长远来看,这应该可以降低您最终陷入包依赖关系的棘手问题的可能性.[2015 年 2 月 13 日]

We will also be changing the behavior of peerDependencies in npm@3. We won’t be automatically downloading the peer dependency anymore. Instead, we’ll warn you if the peer dependency isn’t already installed. This requires you to resolve peerDependency conflicts yourself, manually, but in the long run this should make it less likely that you’ll end up in a tricky spot with your packages’ dependencies. [Feb 13, 2015]

更新

根据 此处 npm@7 现在安装对等依赖项.
有关此决定背后的动机,请参阅此处

Update

As per here npm@7 now installs peer dependencies.
For the motivation behind this decision see here

这篇关于使用纱线安装软件包时,“具有未满足的对等依赖性"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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