bower – installation and quick start guide

Bower is a package manager for web front end frameworks, libraries, assets and utilities. Bower can manage components that contain HTML, CSS, JavaScript, fonts and image files. Here is a quick start guide on Linux or Mac. Note that bower requires git, node and npm.

  1. Install node and npm.
  2. Install bower using npm

    // Skip sudo on Mac if npm is installed as user
    $ sudo npm install -g bower
    
  3. Search available packages using bower search <query>
    $ bower search jquery
    Search results:
        jquery-ui git://github.com/components/jqueryui
        jquery.cookie git://github.com/carhartl/jquery-cookie.git
        jquery-placeholder git://github.com/mathiasbynens/jquery-placeholder.git
    ...
    ...
    
  4. Init bower project and create bower.json
    $ mkdir my_bower_project
    $ cd my_bower_project
    $ bower init
    // You can keep all defaults for the purpose of this tutorial
    $ ls
    bower.json
    $ cat bower.json
    {
      "name": "my_bower_project",
      "authors": [
        "testauthor"
      ],
      "description": "",
      "main": "",
      "moduleType": [],
      "license": "MIT",
      "homepage": "",
      "ignore": [
        "**/.*",
        "node_modules",
        "bower_components",
        "test",
        "tests"
      ]
    }
  5. Install bower package and save dependencies in bower.json (in my_bower_project directory)

    $ bower install jquery --save
    $ ls bower_components/
    jquery 
    $ ls bower_components/jqyery/
    AUTHORS.txt	LICENSE.txt	README.md	bower.json	dist		src
    
  6. Update packages (based on bower.json)

    $ bower update
    
  7. Uninstall a package (say jquery)

    $ bower uninstall jquery
    

    Uninstall a package (say jquery) and save state in bower.json

    $ bower uninstall jquery --save
    
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments