纱线,“未满足的对等依赖性”是什么意思

时间:2019-11-28 06:57:09

标签: yarnpkg

我的package.json是

"peerDependencies": {
    "vue": "^2.6.10",
    "vue-template-compiler": "^2.6.10",
    "webpack": "^4.41.2"
}

当我尝试“纱线安装”时

warning " > sass-loader@8.0.0" has unmet peer dependency "webpack@^4.36.0".
warning "@nuxtjs/vuetify > vuetify-loader@1.4.2" has unmet peer dependency "vue-template-compiler@^2.5.0".
warning "@nuxtjs/vuetify > vuetify-loader@1.4.2" has unmet peer dependency "webpack@^4.0.0".
warning "@nuxtjs/vuetify > vuetify@2.1.12" has unmet peer dependency "vue@^2.6.4".
warning " > ant-design-vue@1.4.7" has unmet peer dependency "vue@>=2.6.6".
warning " > ant-design-vue@1.4.7" has unmet peer dependency "vue-template-compiler@>=2.6.6".
warning "ant-design-vue > @ant-design/icons-vue@2.0.0" has unmet peer dependency "vue@>=2.5.0".
warning "ant-design-vue > @ant-design/icons-vue@2.0.0" has unmet peer dependency "vue-template-compiler@>=2.5.0".

这意味着,我必须在下面安装

"webpack@^4.36.0".
"webpack@^4.0.0".
"vue@^2.6.4".
"vue@>=2.6.6".
"vue@>=2.5.0".
"vue-template-compiler@^2.5.0".
"vue-template-compiler@>=2.6.6".
"vue-template-compiler@>=2.5.0".

您知道,我已经在package.json中包含了webpack,vue,vue-template-compiler,它们是最新版本。

“ ..未满足的对等项依赖关系..”意味着我们必须安装该软件包的确切版本? 如果是这样,如何安装同一软件包的不同版本?

1 个答案:

答案 0 :(得分:1)

您为什么在项目中使用peerDependencies

基于您的问题,我认为这不是故意的:这些依赖项(vue,vue-template-compiler和webpack)应位于dependencies的{​​{1}}或devDependencies中。运行package.json时,将其添加到peerDependencies不会安装它们。

所以要解决您当前的情况:

  • yarn installdependencies中添加项目所需的依赖项(如果您不使用供其他项目使用的库,则无关紧要)
  • 运行devDependencies
  • 如果收到peerDependencies警告,请运行yarn install。当您安装需要在项目中安装特定库的库时,会发生此警告。