permanently ignore a dependency with bower

Pull request #1394 added official support for this feature and is present in bower version 1.6.3 and later. Check your version with bower -v, and run npm install -g bower to upgrade.

For reference, please see the .bowerrc official specification document. If this doesn't work for you, please file an issue with bower because it is a bug.

We use it like this in our .bowerrc such as the following:

{
  "ignoredDependencies": [
    "bootstrap",
    "bootstrap-sass",
    "bootstrap-sass-official"
  ]
}

We had a similar situation where we had Backbone depend on Underscore in its bower.json, but we're using Lo-Dash in its stead, so Bower was unnecessarily pulling down Underscore for each install. We have automated checks for 3rd party license compliance, so we didn't want anything we don't actually use.

I realize this isn't exactly what they're meant for, but Bower's install-hooks can be used to clean unneeded deps post-install (at least until Bower gets the sort of "no thanks" resolution you hinted at). In your .bowerrc:

{
    "directory": "app/bower_components",
    "scripts": {
        "postinstall": "rm -rf app/bower_components/underscore"
    }
}

It's a bit of a hack, but works.


Something you can do also in your bower.json file:

{
  "dependencies": {
    ...
    "bootstrap": "^3.2.0"
  }
  "overrides": {
    "bootstrap": {
      "dependencies": []
    }
  }
}

This means: remove all boostrap's dependencies, which is what you want since jquery is the only one (you can check with bower info bootstrap)


Add it to your .gitignore if you commit your dependencies. Otherwise leave it as it makes no difference. You should just use what you need and ignore the rest.