OpenSource For You
Bower: The Package Manager for Web Applications
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 applications. We need to install a lot of packages while building a website. Bower helps in automatically 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 dependencies that we require for a project.
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 permissions.
Once the installation 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 dependencies that are used in your project. To build a bower. json file, use the following command:
When you type this command, you will be asked a few questions and then you can initialise the bower.json file.
The description of the file properties of bower.json is as follows:
1. name – The name of your application
2. version – A version number for your application
By using Bower, we can add a new package to our project, automatically. Here, we will add Bootstrap to our project by using Bower. To install packages with Bower, use the following commands:
# install dependencies 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