242

I run the following commands using bower 1.0.0:

mkdir testdir;cd testdir
bower init #accept defaults
bower install jquery -s  #the -s is supposed to cause update of bower.json
less bower.json

In bower.json I expect to see dependencies listed, but there are none. What is going on?

NOTE: bower install jquery --save does work

NOTE: The option I am referring to was documented through bower help install

**-S**, --save              Save installed packages into the project's bower.json dependencies
Heekei
  • 45
  • 7
Selah
  • 6,562
  • 6
  • 44
  • 51
  • 7
    why the down vote? – Selah Jul 25 '13 at 18:04
  • 6
    `bower help install`, `--save`, `--save-dev` – madhead Jul 25 '13 at 21:35
  • 6
    `bower help install` says both -s and --save should work equivalently. I'm a bit offended at the suggestion that I did not look at the help... of course I did! I suppose I will edit my question to emphasize that fact. – Selah Jul 29 '13 at 20:36
  • 2
    I'd appreciate removal of the down vote if that is why it was put there. – Selah Jul 29 '13 at 20:43
  • That was not my downvote http://clip2net.com/clip/m48912/1375130702-clip-4kb.png. With my bower installation (0.10.0) `-s` does nothing, just as you described. `--save`, however, works. Also, in my bower help -s is not listed at all! – madhead Jul 29 '13 at 20:43
  • okay... good to know... thanks for the reply! – Selah Jul 29 '13 at 20:44
  • If you happen to upgrade to 1.0.0 and see this issue let me know, please. Perhaps I will file a bug report. – Selah Jul 29 '13 at 20:47
  • Seems like `-s` does not work in 1.0.0, but you still can use `--save` – madhead Jul 29 '13 at 20:53
  • The last edit is correcting the actual problem. It doesn't help such edit, @Heekei – another Jul 12 '17 at 13:24

1 Answers1

380

from bower help, save option has a capital S

-S, --save  Save installed packages into the project's bower.json dependencies
gru
  • 4,483
  • 1
  • 18
  • 22
  • 12
    ok so why would I not want to save it to the dependencies json - I thought the whole idea of this is to track the package...what happens when you just install it ? – landed Feb 26 '14 at 13:51
  • 17
    if you don't use the save flag, it'll just download the package you choose and put it under the bower packages folder, it's a good way of testing a package before setting it into stone. – gru Feb 27 '14 at 15:19
  • 3
    @Gru if you test a package like that, how would you add the package to bower.json afterwards, when successfully tested? Manually? – Robin van Baalen Mar 05 '14 at 17:04
  • 17
    @RobinvanBaalen I've just tried it and if you install the same package a second time with the save option it will add it to bower.json – Qazzian Mar 12 '14 at 15:45
  • 12
    @gru This is indeed useful. I'd be nicer if there was a --trial flag to keep it from being saved since, at least for me, saving to dependencies is more frequent than not. – Joe May 07 '14 at 22:28
  • 2
    yeah, as commented by @RobinvanBaalen, unless you're using something really well known (e.g. angular), one might end up doing a `bower install`, then playing a bit with the library, then if happy running it again with `bower -S install`. the other way round would be to run `bower -S install` immediately, and if not happy just delete the line corresponding to the installed package in `bower.json` – gru May 09 '14 at 08:13