bower learning (two) command

1. Get help

bower --help

2. Custom installation directory packages

New .bowerrc file in the current project, as follows:

{
  "directory" : "js/lib"
}
Once configured, the installation will be located in the resource file js / lib directory.

3.bower initialization

Into the project directory, enter the following command:

bower init

You will be prompted to enter some basic information, follow the prompts to press Enter or the space can be, and then generates a bower.json file, to save the configuration of the project. 

4. Install the latest version of the package

For example the installation jquery, enter the following:

bower install jquery --save
Bower will then download the latest version from the remote to lower your jquery js / lib directory, where --save parameter configuration is saved to your bower.json, you will find bower.json file has more than one line:
"dependencies": {
    "jquery": "~2.1.4"
 }
In addition, bower to install the package also supports the following ways:
# Reads the configuration file bower.json install 
$ Bower install 
# install shorthand by Github 
$ Bower install desandro / Masonry 
installed via Github repository # 
$ Bower install git: // github.com/user/package.git 
# through URL install 
$ Bower install HTTP: // example.com/script.js

5. Install the specified version of the package

bower install jquery#xxx

xxx is the version number

6. Review the information package

bower info jquery

7. Pack updates

If we do not want to use the latest version of jquery, but want to use the old version, how to do?
You can directly modify jquery version bower.json, and then execute the following command:

bower update

9. Find the package

bower support fuzzy search, for example, to find the package that contains the string bootstrap

bower search bootstrap

10. The package unloading

bower uninstall jquery

11. The cache management

  • Clear the cache
bower cache clean
  • Listed cache package
bower cache list
  • By caching the installation package
bower install <package> --offline

12. Open the home page

$ bower home
$ bower home <package>
$ bower home <package>#<version>
If you specify a package name, then open the home page of the package definition. If not specified, then open the current project's home page, usually index.html.

13. List package has been installed

Use the following command to list the current package has been installed, and the available updates.

bower list 
bower list --paths
bower list --paths --json 
-P parameters listed may also be used to route the packet.

14. Find the package name by URL

bower lookup <name>

15. Check bower version

bower --version

Note: Once downloaded will appear in the file bower_components

Guess you like

Origin www.cnblogs.com/kunmomo/p/12514960.html