如何解决Bower依赖版本冲突? [英] How to resolve Bower dependency version conflicts?

查看:95
本文介绍了如何解决Bower依赖版本冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖于这两个项目:

I have a project that depends on both:


  • jquery〜1.9.1

  • 另一个项目又取决于jquery> = 1.7.2

但是当我运行 bower install ,它将最终安装jquery 2.0.2。
这似乎坏了。

But when I run bower install, it ends up installing jquery 2.0.2. This seems broken.

我该如何(a)使其正确解决约束或(b)明确强制安装最终版本(变通方法)?

How do I either (a) make it correctly solve the constraints or (b) explicitly force a final version to be installed (workaround)?

推荐答案

您可以将分辨率添加到 bower.json 文件,并指定组件名称&版本,以在运行Bower命令时自动解决冲突。
像这样:

You can add resolutions to the object in your bower.json file and specify the component name & version to automatically resolve the conflict when running bower commands. Like this:

{
  "name": "project-x",
  "private": true,
  "dependencies": {
    "bootstrap-sass": "~3.3.7",
    "modernizr": "~2.8.3",
    "jquery": "~1.11.3"
  },
  "devDependencies": {},
  "resolutions": {
    "jquery": "~1.11.3"
  }
}

也可以运行 bower install ,并且当bower要求提供合适的版本时(如果启用了交互模式),请在前面加上前缀选择!,这样bower会保存您的选择进入bower.json文件。

Also you can run bower install and when bower will ask for "suitable version" (if interactive mode is on), prefix choice with !, so bower will save your choice into bower.json file.

这篇关于如何解决Bower依赖版本冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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