Unable to find a suitable version for angular - bower install
Asked Answered
U

6

51

I have set up my Angular app so when it's pushed to Heroku it runs bower install. However I'm getting errors due to version issues.

When I run bower install locally I get presented with this:

Unable to find a suitable version for angular, please choose one:                                                                           
    1) angular#1.2.16 which resolved to 1.2.16 and is required by angular-resource#1.2.16                                                   
    2) angular#1.2.23 which resolved to 1.2.23 and is required by angular-cookies#1.2.23                                                    
    3) angular#>= 1.0.8 which resolved to 1.2.25 and is required by angular-ui-router#0.2.10                                                
    4) angular#^1 which resolved to 1.2.25 and is required by angular-ui-codemirror#0.1.6                                                   
    5) angular#~1.2.2 which resolved to 1.2.25 and is required by splitter#f5c2195050                                                       
    6) angular#>=1.0.6 which resolved to 1.2.25 and is required by angular-elastic#2.4.0                                                    
    7) angular#~1.2 which resolved to 1.2.25 and is required by angular-nanoscroller#0.2.1                                                  
    8) angular#~1.2.9 which resolved to 1.2.25 and is required by angular-sockjs#0.0.1Prefix the choice with ! to persist it to bower.json  

? Answer::  

What should I do with this - I actually need version 1.3 of Angular because of the debounce feature

My bower.json looks like this:

{
  "name": "myapp",
  "version": "0.0.1",
  "dependencies": {
    "json3": "~3.3.1",
    "es5-shim": "~3.1.0",
    "angular-resource": "1.2.16",
    "angular-sanitize": "1.2.16",
    "angular-animate": "1.2.16",
    "angular-ui-router": "~0.2.10",
    "jquery": "~2.1.1",
    "angular-ui-codemirror": "~0.1.6",
    "splitter": "*",
    "angular-cookies": "~1.2.23",
    "angular-elastic": "~2.4.0",
    "angular-local-storage": "~0.0.7",
    "chance": "~0.5.6",
    "nanoscroller": "~0.8.4",
    "angular-nanoscroller": "~0.2.1",
    "angular-sockjs": "~0.0.1"
  }
}
Unfolded answered 18/9, 2014 at 14:40 Comment(0)
H
77

Update your current angular dependencies to 1.3.x and add a resolution for angular to suppress the prompt:

{
  "name": "myapp",
  "version": "0.0.1",
  "dependencies": {
    "angular": "~1.3.x",
    "angular-animate": "~1.3.x",
    "angular-cookies": "~1.3.x",
    "angular-resource": "~1.3.x",
    "angular-sanitize": "~1.3.x",
    "angular-ui-router": "~0.2.10",
    "angular-ui-codemirror": "~0.1.6",
    "angular-elastic": "~2.4.0",
    "angular-local-storage": "~0.0.7",
    "angular-nanoscroller": "~0.2.1",
    "angular-sockjs": ">=0.0.1",
    "json3": "~3.3.1",
    "es5-shim": "~3.1.0",
    "jquery": "~2.1.1",
    "splitter": "*",
    "chance": "~0.5.6",
    "nanoscroller": "~0.8.4"
  },
  "resolutions": {
    "angular": "~1.3.x"
  }
}
Harrier answered 18/9, 2014 at 14:59 Comment(3)
Sorry, but can you tell me will there be any problem with angular-ui-router (#0.2.10) since it uses older angular? My doubt is can I every time go with the latest version blindly?Hyperopia
@AsimKT Did you manage to find a strategy to deal with these kind of issues? I mean it is quite frustrating at times because you find that you are using a module that depends on an older version of angular and there is another one added by another dev depending on the later version and they are both very important to your projects!! I wonder how other teams are dealing with this issue!!Keyte
No, I haven't. I think it's okay to go with new versions if it's not a major release change. I need a plugin for my project which have this issue. I used the latest dependency and it worked okay. Although I raised an issue in their repo to bump the version and they did. And you are right, we all face these issues!!Hyperopia
A
20

A very good explanation and resolution of the issue can be found here:

bower-resolutions

Just copy pasting some lines here for reference:

When you specify dependencies for you app via Bower, some of the packages might rely on different versions of the same library. You will have to resolve what version of libraries your app actually wants. In other words, you break the tie. But you don’t want to break it every time, so save your choice.

When you run bower install, the resolution process is interactive. When bower recognizes that there are two packages that depend on a package at different versions, it’ll list all those versions and ask:

enter image description here

The next line in the prompt is very handy. It reads:

enter image description here

Awesome! So, if I type !2 instead, my choice is saved in bower.json. Specifically, it’ll add a resolutions entry:

enter image description here

Now, the next time you run bower install, there is no interactive question of what version I want because I’ve already resolved that ember for my app should be version 1.5.1.

Adames answered 6/10, 2015 at 6:34 Comment(0)
S
9

You should update bower (It works for me):

bower update
Shortcircuit answered 4/4, 2016 at 19:24 Comment(0)
R
5

Delete your /bower_components directory and run bower install again..

A hack but works nevertheless..!!

Related answered 11/8, 2016 at 12:8 Comment(0)
V
1

You can run the install command and when it prompts for selection of version then use (!) exclamation mark as prefix to option. For example !3 for third option. This would then get added to bower.json file of your application and resolve the conflict.

Hope this helps.

Virago answered 13/12, 2016 at 14:24 Comment(0)
T
0

First try this:
npm install -g bower

If above solution does not work then, Try:

bower update
Worked for me.
Templetempler answered 17/10, 2018 at 6:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.