[Getting Started]bower installation and use

Source: Internet
Author: User
Tags git client using git

Bower Installation and usewords 745 Read 10127 comments 2 likes 3 Installation of Bower

1, first install Nodejson my system. Because my system is windows, I also need to install msysgit, note the options in Figure two


Msysgit


Git Setup

2, you can then download and globally install Bowerwith the NPM Package management tool:

>NPM Install-g Bower

After you install bower globally, you can view Bower's help information by using the command:

>bower Help

3, initialize the current project's bower, this operation will generate the Bower.json file in the current directory:

>bower Init

Use of Bower

Projects that use Bower will have a Bower.json file in the directory. Under this file sibling directory, use the following command to install the dependent libraries.

>bower Install

Note: Bower download and install dependent libraries are actually downloaded using git. For Linux systems, there is no problem because Git is installed by default. But Windows systems generally do not have git. You need to make sure that you have a GIT client installed under Windows, and we recommend using the same bundled git bash command line to execute the Bower install command. or add the Git directory to the environment variable in Windows, and then execute the Bower Install command on the command line. ()

Use Bower to install a particular class library, such as jquery:

> Bower Install jquery

Use Bower to update a particular class library, such as jquery:

>bower Update jquery

Delete a package, such as jquery (cannot be deleted if the package is already dependent)

>bower Uninstall jquery

Try to download jquery and underscore under the project folder

Bower Install jquery underscore

Then you can see the project folder is more bower_components (default directory), and then two plug-in package


Bower_components

Initially this is OK, but/bower_components this directory is a bit uncomfortable, I want to download things in my accustomed directory. Need to add a . bowerrc file . Notice that you don't need a name for anything , just add a. BOWERRC on the line.

Tip: Create a file with the cmd command as follows


CMD Create file


. BOWERRRC

Inside you can define the download directory:

{

"Directory": "App/vendor"

}


. BOWERRC Configuration

For more configuration on. BOWERRC, refer to
Https://github.com/bower/spec/blob/master/config.md

The same cmd command is executed again, this time you can see the file downloaded to App/vendor.


Download to the specified directory

Because the command was not run during the actual installation, >bower init now rerun the command to generate Bower.json

I'm having problems.


Bower Init failed

Workaround: use bower init inside windows cmd instead of using bower init inside git bash.


Init settings

Use the Bower install jquery --save to write jquery dependencies into Bower.json.
To install a version using #, such as installing juqery1.9.1, you can use Bower install jquery#1.9.1.
In addition to installing with the package name, you can also specify a git address to install, such as Bower install Https://github.com/jquery/jquery.

Bower Install--save handlebars will see handlebar in Bower.json dependencies, if not add--save will not have.


Handlebars

Next delete all the content under App/vendor, then Bower install, he will bower.json in the dependencies re-download.

    • Bower solves JS's dependency management-cross-border it blogs, core It technologies include: Hadoop, R, Rhadoop, Nodejs, AngularJS, KVM, NoSQL, it finance a little rookie? blog.fens.me→

[Getting Started]bower installation and use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.