Bower

Bower works by fetching and installing packages from all over, taking care of hunting, finding, downloading, and saving the stuff you’re looking for. Bower keeps track of these packages in a manifest file, bower.json. How you use packages is up to you. Bower provides hooks to facilitate using packages in your tools and workflows.

 

Getting Started

Bower requires Node and npm and Git.

Git Bash

Search Bower packages (http://bower.io/search) – search for common package names and dependencies.

  1. Install Node JS from http://nodejs.org/
  2. Add NodeJs to Windows PATH environment variable PATH=C:\Program Files\nodejs\ Restart Windows for IntelliJ to pick this up.
  3. Bower is a command line utility. Install it with npm. globally npm install -g bower
  4. Add Git Bash to Windows PATH environment variable PATH=C:\Program Files (x86)\Git\bin; Restart IntelliJ to pick this up.
  5. Install packages with bower install. Bower installs packages to bower_components/. i.e bower install bootstrap
    bower install <package>
  6. Save your packages to bower.json with bower init

Dependency packages are installed into your Windows account profile i.e;

D:\WorkspacePearsonBtecSpecs\spring-mvc-angularjs-sample-app-master>npm install -g bower
C:\Users\dawud\AppData\Roaming\npm\bower -> C:\Users\dawud\AppData\Roaming\npm\node_modules\bower\bin\bower
bower@1.3.12 C:\Users\dawud\AppData\Roaming\npm\node_modules\bower

Example

We are using Bower to install client side dependencies. This step updates the bower.json configuration file to include the new dependency:

{
  "name": "angular-seed",
  "description": "A starter project for AngularJS",
  "version": "0.0.0",
  "homepage": "https://github.com/angular/angular-seed",
  "license": "MIT",
  "private": true,
  "dependencies": {
    "angular": "1.4.x",
    "angular-mocks": "1.4.x",
    "jquery": "~2.1.1",
    "bootstrap": "~3.1.1",
    "angular-route": "1.4.x",
    "angular-resource": "1.4.x"
  }
}

The new dependency "angular-resource": "1.4.x" tells bower to install a version of the angular-resource component that is compatible with version 1.4.x. We must ask bower to download and install this dependency. We can do this by running:

npm install
Warning: If a new version of Angular has been released since you last ran npm install, then you may have a problem with the bower install due to a conflict between the versions of angular.js that need to be installed. If you get this then simply delete your app/bower_components folder before running npm install.
Note: If you have bower installed globally then you can run bower install but for this project we have preconfigured npm install to run bower for us.

 

 

Website

 

References

IntelliJ – Using Bower Package Manager