Search code examples
javascriptnpmbowerbower-installsemantic-versioning

Instruct bower to use exact version by default, not range


When one issues a bower install mypackage --save, by default, for version, bower uses the tilde range selector (~) prefix for the latest patch version:

"angular-ui-grid": "~3.1.0"

Because in reality patch versions do cause breaking changes (we've experienced this four times now with our dependencies packages), we'd like to change the behavior to use exact version semver instead:

"angular-ui-grid": "3.1.0"

Is there a way to automatically enforce this or set exact match to the default? I can't expect members of the dev team to remember to delete the ~ everytime they add a bower package.


Solution

  • Have you read the documentation? It looks like -E or --save-exact is what you need.

    Edit: just tested it. That's what you need. Your command would then be

    bower install mypackage --save-exact
    

    If you want to have that be the default, create a .bowerrc in your home directory and/or in the project directory like:

    {
      "save-exact": true
    }