Skip to content

Instantly share code, notes, and snippets.

@alemohamad
Last active August 29, 2015 14:14
Show Gist options
  • Save alemohamad/e056a1aa6a8ddca07651 to your computer and use it in GitHub Desktop.
Save alemohamad/e056a1aa6a8ddca07651 to your computer and use it in GitHub Desktop.

Bower

Bower

Bower is a package manager for the web.

Install NodeJS

Go to http://nodejs.org/ and download the installer.
Then to verify that NodeJS is installed, write the following:

$ node -v

Install Bower with NodeJS

$ npm install -g bower

Add jQuery with Bower

$ bower install jquery

Install a specific version:

$ bower install jquery#1.9.1

View which packages Bower has

$ bower list
$ bower list --paths

Then you can add the JS file with the path to the HTML code.

Uninstall packages

$ bower uninstall jquery

If you find a repo that doesn't appear at Bower, you can use a github url:

$ bower install <github_url>

Add a Bower repository file

This is to define which dependencies JS libraries the project has. If you already installed some packages to the project, Bower adds them to the file for you.

$ bower init

With this, you can add a .gitignore file, where it ignores the "bower_components" folder when you commit to the git repo. It saves some space.
If you checkout the repo and want to download the JS libraries, all you have to do is:

$ bower install

If you want to add a new package, and want to be at the json file, you have to do it in the following way (add at the end -S):

$ bower install jquery -S
# or
$ bower install --save jquery

Installing Bootstrap

Bower can also install CSS libraries, not only JS libraries.

$ bower install bootstrap

Video tutorial

https://www.youtube.com/watch?v=Vs2wduoN9Ws

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment