Update multiple dependencies with Bower

2019-02-01 16:24发布

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?

4条回答
叼着烟拽天下
2楼-- · 2019-02-01 16:37

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.

查看更多
Viruses.
3楼-- · 2019-02-01 16:42

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

npm install -g bower-update-all
bower-update-all
查看更多
再贱就再见
4楼-- · 2019-02-01 16:50

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"
   }
 }
查看更多
男人必须洒脱
5楼-- · 2019-02-01 17:02

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

查看更多
登录 后发表回答