Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to force bower to install a certain version of dependency

Tags:

bower

Assume a bower.json file in which dependencies are like

"dependencies": {     "angular": "~1.5.x",     "angular-routing": "*",     "ngDialog": "*",     "requirejs": "*" } 

because angular-routing requires another version of angular (say 1.2.x), bower prompts me to choose a version.

How could I force bower to install angular ~1.5.x automatically?

like image 219
Reyraa Avatar asked Feb 08 '16 15:02

Reyraa


People also ask

How do you get the latest version of the dependencies as per the json file installed?

You can find the latest version of the npm added in package. json file. If you want to add the latest version either you can run npm install or npm install @latest .

How do I update bower json?

If there aren't that many bower packages you have installed, try writing bower install [package_name] --save . This will just update your bower. json file.

Is bower still relevant?

Bower has been deprecated by its creators After a long and heated debate on Github, the creators of Bower decided it does not add value to the current web development stack and should be discontinued.

Is git essential for installing bower True or false?

Q. 6 Is Git essential for installing Bower? A. Yes, as Git is required to access the packages for inclusion.


1 Answers

I figured out the answer. I'm sharing for others:

If I add the dependency with my favorite version to resolutions in bower.json, Bower will automatically install it. Here is my updated bower.json:

"dependencies": {   "angular": "~1.5.x",   "angular-routing": "*",   "ngDialog": "*",   "requirejs": "*" }, "resolutions": {   "angular": "~1.5.x" } 

More information here.

Update:
As Mattliu mentioned in comments, it's possible to answer with ! when any library asks for another version of an already installed dependency. this way you'll keep existing version and also npm creates resolution config automatically.

like image 157
Reyraa Avatar answered Sep 23 '22 23:09

Reyraa