Bower and the “ECONFLICT Unable to find suitable version for angular” issue

Reading Time: 2 minutes

AngularJSPlusBowerWhile developing on a hybrid app project based on AngularJS I noticed that executing bower install <library> –save for a new library that I need to include resulted not in the library being added, but in an awfully indirect error message:

 ECONFLICT Unable to find suitable version for angular

WTF

WTF??!!!

Like most of the time I’d check the bower.json file to see what Angular version I have installed and go to the libraries bower.json file or check the github page to find out what versions it supports. But no more!

I’ve taken the time to find out how to fix this issue and found a solid answer on how to fix this fast and furious in case I’ll get into a Bower standoff again…

It seems there is CLI syntax to the resque for this issue. The issue (most of the time) appears to be caused when the package you are about to add is newer and depending on newer (or at least, a different) Angular version then the one nested in your project. Updating the bower setup is what can fix this. But not mindlessly though!… To keep one from screwing up their carefully appended bower setup here’s a safe route to fixing the ECONFLICT:

  1. Decide if you can update your bower dependancies like a wild goose chasing a dog (or not).
    • If you’re absolutely depending on a specific version or your application is already in production going 100 miles an hour go the old route and check if there is a suiting specific version for the library you want to add. Go to step 5 and live prosper.
    • When the previous bullit isn’t describing your situation, go to step 2.
  2. If you can update your bower dependancies, roll up your sleeves and do the following:
    • make sure you REALLY didn’t alter any bower libraries on the spot since the delta will be erased by the following actions! If that is the case proceed to step 3
  3. Choose one of the following actions
    • remove all bower_components subdirectories (no worries, your bower.json keeps track of what you need, run:
      $bower install
      followed by running the next command once again:
      $bower install <library> –save
      (source: my own guts)
      Go to step 4
    • run the following command (source: GitHub issue 866)
      $bower install –force-latest
      Go to step 4
    • add the version for angular that the library needs under the resolutions key in bower.json to force that version. This will also prevent bower from asking you to choose between different versions that other libraries are depending on – oh boy, do I hate choosing on the spot like that!  (source: GitHub issue 866). Go to step 4
  4. Watch Bower installing your goodies
  5. Verify that the ECONFLICT has vanished and..

Live long and prosperLive long and prosper

Hope this helps you getting this one out of the way!