49

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?

kaiser
  • 21,817
  • 17
  • 90
  • 110

4 Answers4

79

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.

Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
  • Finally! Thanks! ... had overread the last help line that states that. – kaiser Aug 07 '13 at 16:22
  • 1
    Not worked for me. The bootstrap version for example is in 3.2.0 version. I've tried do bower update bootstrap but it not updates to 3.3.0 that is the current one. – Shad Oct 30 '14 at 23:06
  • 1
    did you specify a version number in your bower.json? – Nict Nov 26 '14 at 17:44
  • 1
    Note that doing this, it will respect the versions specified in your file. If your specified Boostrap version is `~3.2.0`, it will never update to 3.3. If you want something more violent, you could use something like https://www.npmjs.com/package/bower-update-all – Deurco Sep 17 '15 at 10:22
  • @Deurco How might one force an update to the latest when you have the ~ in use? – JagWire Sep 28 '15 at 13:37
  • 5
    @JagWire By reinstalling the package. Simply run `bower install {package-name} --save` and the version in `bower.json` will be ignored. That is what [bower-update-all](https://www.npmjs.com/package/bower-update-all) does, for each of your packages, in one command (of course, this could break your app, since it could apply versions with breaking changes). – Deurco Sep 28 '15 at 13:54
  • `-h` stands for **help**, to force update use `--force-latest` or `-F` – Leo Caseiro Apr 21 '16 at 06:06
7

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"
   }
 }
Ricardo Rivas
  • 620
  • 6
  • 8
  • 1
    No, `npm install --save bootstrap` will load the latest tag of bootstrap and save it to the deps. At the time writing this it will be `"bootstrap": "~3.2.0"` – kernel Oct 21 '14 at 13:05
2

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

npm install -g bower-update-all
bower-update-all
Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
1

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

Jacob Phillips
  • 8,841
  • 3
  • 51
  • 66