Just like we use NPM for managing Node.js modules (which are stored in the node_modules
folder), we use Bower (available at http://bower.io/) for managing dependencies on the frontend (which are stored in the bower_components
folder). Suppose you want to use UnderscoreJS (available at http://underscorejs.org/), you can install it using the following command:
bower install underscore
This will download underscore in the bower_components
folder, but it doesn't make changes to the bower.json
file. However, we want that if any other team member pulls the latest source code, he too should get a copy of underscore on his machine. So we can run the following code:
bower install underscore --save
This adds an entry for underscore in the dependencies
section of the bower.json
file. However, if we want to install it as a dev-dependency, we need to run the following code:
bower install underscore --save-dev
This adds an entry for underscore in the devDependencies
section of the bower.json
file.
Note
There are certain packages which we need only during development; for example, unit or mock testing libraries or even grunt itself. We don't want to ship any of these to the client. Consequently, both package.json
and bower.json
files have dependencies and devDependencies
sections. The devDependencies
section contains names of packages needed only during development.