Asim K T
Asim K T

Reputation: 18144

What's resolutions and overrides in a `bower.json` file?

In a bower.json file, what are the resolution and overrides properties used for?

{
  "name": "name",
  "dependencies": {
    "angular": "~1.4.8",
    ...
    "jquery": "2.2.4"
  },
  "overrides": {
    "ionic": {
      "main": [
        "release/js/ionic.js",
        "release/js/ionic-angular.js"
      ]
    }
  },
  "resolutions": {
    "angular-ui-router": "~0.2.15",
    "angular": "~1.5.3"
  }
}

Upvotes: 16

Views: 14269

Answers (3)

VadimB
VadimB

Reputation: 5711

Resolution

The resolution section appears when you need to resolve dependency versions (after bower install) when conflicts occur. It's for making a decision regarding which concrete version of a dependency to use when the need to resolve dependency conflicts arises - bower automatically injects this decision as the "resolution" record. So the next time a conflict occurs (when updating the dependency tree, etc), the resolved version will be based on the "resolution" data in your configuration file.

An example dependency version conflict resolution prompt. The text in the image states: "Unable to find a suitable version for ember, please choose one: 1) ember#~1.0.0 which resolved to 1.0.1 and is required by ember-data#0. 2) ember#1.5.1 which resolved to 1.5.1 and required by melodrama"

Overrides

Overrides section is used to override the file(s) references when pointing to dependent library.

Task runners in most cases use the bower configuration library metadata to inject links to these libraries into a page's content. When we want to inject a bootstrap link into a page, we do not need to go into the "bower_components" folder, find the package, and investigate the file content. We can use the component metadata to find the main, injectable file reference.

The "overrides" section is used to change this data to use another file, or even a set of files, as a package's main entry point.

An example overrides section configuration for the bootstrap-sass-official package.

Upvotes: 15

Alex Denisov
Alex Denisov

Reputation: 254

Multiple Bower packages can list different versions of the same library as a dependency. The resolutions section specifies which version of the library to use whenever this type of situation occurs. If not specified in bower.json, you will receive a command line prompt upon running bower install.

The overrides section makes it possible to override default paths to assets installed through Bower when using a task runner like Gulp. If you intend to move files from their default location in the bower_components folder to accommodate your build process, for example, it could prove handy in this type of setup.

Upvotes: 4

Anurag_Soni
Anurag_Soni

Reputation: 542

We use resolutions object in your bower.json file to specify the component name & version to automatically resolve the conflict when running bower commands.

Overrides section is used to override the file(s) references when pointing to dependent library.

Upvotes: 0

Related Questions