简体   繁体   中英

Bower: Cannot find suitable version for Angular

this is probably a newbie question, but i do not understand why bower (1.7.9) cannot find a suitable version for Angular when i run:

bower install

or when it cannot find a suitable version for Angular-translate when i run:

bower update

(Why does it even give me a different error when i run either command in the above?)

I have updated every package to their latest versions and I did not find any package which would require an older version of Angular. Here is my bower.json:

 { "name": "test", "homepage": "http://www.google.nl", "version": "0.2.1", "ignore": [ ".jshintrc", "**/*.txt" ], "dependencies": { "angular": "1.5.9", "angular-animate": "1.6.0-rc.2", "angular-bootstrap": "2.3.0", "angular-cookies": "1.6.0-rc.2", "angular-hotkeys": "0.2.2", "angular-i18n": "1.6.0-rc.2", "angular-route": "1.6.0-rc.2", "angular-translate": "2.13.1", "angular-sanitize": "1.6.0-rc.2", "angular-translate-loader-static-files": "2.8.1", "angular-ui-bootstrap-datetimepicker": "2.0.3", "angular-loading-bar": "0.9.0", "jquery": "3.1.1", "moment": "2.17.1", "ng-dialog": "0.6.4", "ng-focus-if": "1.0.7", "ng-tags-input": "3.1.1", "ngInfiniteScroll": "https://github.com/hlsolutions/ngInfiniteScroll.git#scroll-on-any-lement", "angular-ui-select": "0.19.6", "placeholders": "https://github.com/jamesallardice/Placeholders.js.git#~4.0.1", "angular-atomic-notify": "~1.0.3", "underscore": "https://github.com/components/underscore.git#~1.8.3", "angulartics-google-analytics": "0.4.0", "angular-ui-tinymce": "~0.0.17", "angular-collection": "~0.5.2", "angular-mocks": "1.6.0-rc.2", "angular-translate-handler-log": "2.13.1" } } 

The problem I see is related to:

"angular-translate": "2.13.1",
...
"angular-translate-loader-static-files": "2.8.1",

The problem is: - you are requesting exact versions - angular-translate-loader-static-files also requests angular-translate, but it demands the same version (2.8.1) - bower does not allow multiple version of the same library

One solution would be: "angular-translate-loader-static-files": "2.13.1"

The same problem is with angular, you should use "angular": "1.6.0-rc.2" since you already request this version for other modules that depend on angular.

However, this is not necessarily the best way to go, because for example I see you are using some libraries that want angular < 1.6 (ngInfiniteScroll) so you will not be able to make these work in your project if you really want to use the 1.6 version.

A better idea would be to require version more loosely (eg "angular": ">=1.5.x"), then let bower find the most suitable version for all your dependencies - but this will most likely require you to work with older versions or risk incompatibility issues.

It often happens when you already have an old version of a library (here it's angular) downloaded in your bower_components of your project.

Generally to fix this, i just empty my bower_components before redo a bower install and everything get back to the normal.

Hope this will help in your case.

See if the final answer to a similar question helps

"Instead of running bower install library -save I did added the latest versions of the libraries directly to my bower.json and added the resolutions..."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM