bower

bower

bower is client side package management tool.
This is similar with nodejs npm.

Install bower

Use npm

npm install -g bower

By it, bower was installed under your node_modules as global

Install package

bower install packagename

If you want to set version, please add #version

npm install angular#1.4.6

Uninstall package

bower uninstall packagename

How to use with nodejs express

init bower

To create package file in your project, move your project root and run following command

bower init

bower.json will be created under your project root.

Add package for this project

Let’s add client components.

{
  "name": "app-name",
  "version": "0.0.1",
  "dependencies": {
    "angular": "~1.4.5"
  },
  "private": "true"
}

This is example of angular for bower.

If you want to search packages for bower, you can use search

bower search pakcagename

Install package

After finishing, you need to run install command to install
You can add new project anytime. After adding package, you can run install command and package will be installed.

bower install

By default, bower_components is install directory under your project.

bower_components
  | - angular
        | - angualr.js

Change directory

In nodejs express, /public is javascript or other static resource store.
By default, bower package install place is under bower_components/.
To change it, we need to create .bowerrc.
.bowerrc

{
  "directory" : "public/bower"
}

In this example, package root is under public/bower.

If you want to know other parameters, please see bower config