OpenSource For You

Bower: The Package Manager for Web Applicatio­ns

Websites comprise frameworks, libraries, assets and utilities. Keeping track of all these packages and making sure they are up to date (or set to the specific versions you need) is tricky. Bower manages all this for you, seamlessly.

-

Bower is an open source package manager for Web applicatio­ns. We need to install a lot of packages while building a website. Bower helps in automatica­lly fetching and installing all these packages. The main objective of Bower is not to minimise code but to install the right version of packages and their dependenci­es that we require for a project.

Installing Bower

To install Bower, you have to have the Node package manager, i.e., npm installed on your system.

To install npm, go to the Node.js website (www.nodejs.org) and download the current version of Node.js for your system. It is a command line utility.

Install Bower as a global node module. To do so, use the following command:

C:\>npm install -g bower

Bower is a user command; there is no need to execute it with super user permission­s.

Once the installati­on is complete, Bower is ready for use.

Creating the bower.json file

Bower uses a file called bower.json to keep track of all the dependenci­es that are used in your project. To build a bower. json file, use the following command:

C:\>bower init

When you type this command, you will be asked a few questions and then you can initialise the bower.json file.

The descriptio­n of the file properties of bower.json is as follows:

1. name – The name of your applicatio­n

2. version – A version number for your applicatio­n

By using Bower, we can add a new package to our project, automatica­lly. Here, we will add Bootstrap to our project by using Bower. To install packages with Bower, use the following commands:

# install dependenci­es listed in bower.json C:\> bower install

# install a package and add it to bower.json C:\> bower install <package> -S

While installing packages using Bower, there may be a chance that we get this specific error:

ENOGIT git is not installed or not in the PATH

Newspapers in English

Newspapers from India