How to resolve Bower dependency version conflicts?
Asked Answered
P

2

68

I have a project that depends on both:

  • jquery ~1.9.1
  • another project which in turn depends on jquery >=1.7.2

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

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

Precession answered 7/6, 2013 at 18:58 Comment(4)
Ticket: github.com/bower/bower/issues/540Giraudoux
you would have 2 projects here - so one would get one version of jQ and the other a different version so I am thinking you need more detail in your question.Footgear
Have you found a solution to this problem, as I am having the exact same thing and neilhem's solution doesn't work for me (as in, it didn't make any difference)?Hermaphroditus
my work around is run bower install jQuery#2.1.4 --saveApocalyptic
P
114

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"
  }
}

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.

Pruter answered 18/6, 2014 at 8:54 Comment(7)
This solution doesn't work for me. It doesn't seem to make a difference. Does it require a certain version of Bower and mine happens to be too old (it's installed from npm, so whatever that version is).Hermaphroditus
@Hermaphroditus try to update bower running: npm update -g bowerPruter
Great answer. This should be marked as correct. Putting ! in front of the choice was extra helpful.Unconditioned
To add to @neilhem answer: bower install will not ask "suitable version" if interactive mode is off. more informationDeuced
Anything like this for npm (package.json)?Hinton
@AlonAmir npm uses nested dependency tree. More here #18642399Pruter
You can also save your resolution typing the chose number + !, eg: 2!Artima
C
0

use --force-latest

enter link description here

Chatter answered 24/12, 2018 at 15:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.