Update multiple dependencies with Bower

2019-02-01 16:31发布

问题:

I listed (and/or installed) several dependencies with Bower inside the bower.json file and/or with

bower install https://github.com/username/project.git

That worked fine.

Now I can list all them with

bower list

and then I can pick the name of each dependency of my project and run

bower update dependency-name

Question: How can I bulk update all of them? Or do I have to write a shell script to loop through and update them?

回答1:

You can update all by running bower update.

Use the -h flag on any command to see how you can use it. Eg bower update -h.



回答2:

This process is a little slow but is secure because you can realize when your app gets broken.

lets say that you want to update bootstrap you just need to run bower install --save bootstrap and you bower.json file will be updated

Before

 {
   "name": "my-awesome-app",
   "version": "0.0.0",
   "dependencies": {
     "bootstrap": "~3.0.0",
     "requirejs": "~2.1.11",
     "modernizr": "~2.8.2",
     "jquery": "~2.1.1",
     "underscore-amd": "~1.5.2",
     "backbone-amd": "~1.1.0",                                                                                                                                                
     "require-handlebars-plugin": "~0.8.0"
   }
 }

After

 {
   "name": "my-awesome-app",
   "version": "0.0.0",
   "dependencies": {
     "bootstrap": "~3.3.1",
     "requirejs": "~2.1.11",
     "modernizr": "~2.8.2",
     "jquery": "~2.1.1",
     "underscore-amd": "~1.5.2",
     "backbone-amd": "~1.1.0",                                                                                                                                                
     "require-handlebars-plugin": "~0.8.0"
   }
 }


回答3:

Used bower-update-all to update all bower dependencies in bower.json, as follows:

npm install -g bower-update-all
bower-update-all


回答4:

If you want to force all dependencies to update you can use bower install --save --force. This is the same as bower install --save [dep1] [dep2] ...

The short version is bower i -S -f