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