X

Bower the package manager for web front-end

bower

My last blog post was about using bower in node.js express application Visual Studio, and I believe I did not do justice to it. In this blog post I will talk more about how to use bower for your front-end and all the command line associate with bower.

Again to install bower globally one can use the npm command line

npm install -g bower

To start using bower and to find packages e.g jquery, it will list out all the github repository that has jquery involved.

bower search jquery

Installing Packages

To install latest jquery or by a version number we can append it with a “#” symbol like below, or by a git repo

bower install jquery

bower install jquery#1.9.1

bower install git://github.com/pivotal/jasmine.git

In order to use jquery with bower on your site you can reference it in your html like


Uninstall or Update a package

To uninstall or to upgrade a package e.g jquery

bower upgrade jquery

bower uninstall jquery

To upgrade all installed packages one just needs to use

bower upgrade

List installed packages

If one wants to find out what packages are installed in the solution one can use the command ls or list

bower ls
or
bower list

Information on a package

To find out information and version of a package that bower provides one can use the info command

bower info jquery

One can also find out which repository bower is using for a package using the lookup command

bower lookup jquery

Output:
jquery git://github.com/jquery/jquery.git

There is also the home command which takes you the homepage of the repository, the below command will take you the github repository of jquery

bower home jquery

Caching

Bower has a caching where when you run the install it will automatically download the package to your ~/.bower/cache so that when you run install again it will just use the cache version for a quicker install, on windows you will find bower cache to be located at C:\Users\YourUsername\AppData\Roaming\bower\cache and on unix/linux systems in your home directory ~/.bower/cache

One can also clear the cache by using the command cache-clear.

bower clear-cache

And last but not least there is also help command

bower help

In my next blog I will write about how to create your own bower packages and all about bower.json file.

Categories: Node
Taswar Bhatti:
Related Post