zoukankan      html  css  js  c++  java
  • bower使用记录

    每次做项目的时候都不依赖某一个库来开发,每次需要某一个库的时候都是百度进入库官网再找到下载的库,经常会因为官网的改版更新而在里面绕半天找不到想要的版本号,当然直接去github,CDN 都可以找到需要的库,但是总感觉这样很不优雅,直到偶然发现Bower,一个web的包管理工具,发现从此找库是一件很优雅的事。

    Bower安装

    Bower基于node,所以电脑必须安装node,还需安装node包管理工具npm

    npm install bower -g//全局安装bower,必须加-g
    bower --version//查看当前安装的版本号,如有输出版本号则安装成功

    Bower命令

    在命令行工具中输入bower可以查看到bower所有可用的命令

    E:>bower
    
    Usage:
    
        bower <command> [<args>] [<options>]
    Commands:
    
        cache                   Manage bower cache
        help                    Display help information about Bower
        home                    Opens a package homepage into your fav
        info                    Info of a particular package
        init                    Interactively create a bower.json file
        install                 Install a package locally
        link                    Symlink a package folder
        list                    List local packages - and possible upd
        login                   Authenticate with GitHub and store cre
        lookup                  Look up a single package URL by name
        prune                   Removes local extraneous packages
        register                Register a package
        search                  Search for packages by name
        update                  Update a local package
        uninstall               Remove a local package
        unregister              Remove a package from the registry
        version                 Bump a package version
    Options:
    
        -f, --force             Makes various commands more forceful
        -j, --json              Output consumable JSON
        -l, --loglevel          What level of logs to report
        -o, --offline           Do not hit the network
        -q, --quiet             Only output important information
        -s, --silent            Do not output anything, besides errors
        -V, --verbose           Makes output more verbose
        --allow-root            Allows running commands as root
        -v, --version           Output Bower version
        --no-color              Disable colors

    Bower常用命令记录

    1:项目初始化

    bower init//初始化项目,生成bower.json文件,记录库信息,供二次使用,在安装库的时候只需加--save便会把当前库自动写入bower.json文件,
    把bower.json文件拷到指定的目录,只需直接运行bower install会自动安装指定的库列表

    2:下载项目需要库,使用命令install

    此处以下载神库jquery为示例:

    bower install jquery//下载最新的jquery库到本地
    bower install jquery#1.11.3//下载1.11.3版本的jquery库到本地
    bower info jquery//可查看到当前jquery库所有的版本,再下载自己所需要版本

    3:查看当前已经安装了的库

    bower list//可查看当前目录下已经下载了的库列表,对于需要依赖别的库的文件也能看到它所依赖的库列表

    4:删除不需要的库

    bower uninstall jquery//删除jquery库

    5:升级已下载的库

    bower update jquery//更新jquery库

    6:查看库的github地址

    bower lookup jquery//查看jquery的github库地址
    bower home jquery//直接打开jquery库的github地址

    7:bower配置文件.bowerrc

    {
      "directory" : "components",//js库下载到的目录
      "json"      : "bower.json",//库列表文件
      "endpoint"  : "https://Bower.herokuapp.com",//在线索引的网址,用来搜索各种库。
      "searchpath"  : [],//一个数组,储存备选的在线索引网址。如果某个库在endpoint中找不到,则继续搜索该属性指定的网址,通常用于放置某些不公开的库。
      "shorthand_resolver" : ""//定义各个库名称简写形式。
    }

    上面这些是我在工作中常用到的命令,其实工作中也只是用来拉一下库文件而已,感觉也是帮大忙了。

    注意:bower需要电脑装有git版本管理工具,不然会报如下错:ENOGIT git is not installed or not in the PATH安装git并设置环境变量

    解决方法一:

    添加git到window的环境变量中。设置path路径为C:Program FilesGitin

    解决方法二:

    在不用添加环境变量的情况下,运行下面一个命令,就可以设置当前文件加的环境变量。

    set PATH=%PATH%;C:Program FilesGitin

    亲身掉进过这个坑,查看到git安装目录,再设置全局变量到指定的BIN文件夹,方法一设置后要重启CMD才起作用,方法二能及时起作用。

    以上解决方案参见:http://www.haorooms.com/post/bower_error

  • 相关阅读:
    ORB随便记一记
    POJ 树的直径和重心
    LeetCode 834. Sum of Distances in Tree
    LeetCode 214. Shortest Palindrome
    DWA局部路径规划算法论文阅读:The Dynamic Window Approach to Collision Avoidance。
    坐标变换
    论文阅读:hector_slam: A Flexible and Scalable SLAM System with Full 3D Motion Estimation.
    POJ 尺取法
    POJ 博弈论
    oracle锁表
  • 原文地址:https://www.cnblogs.com/xwwin/p/6080367.html
Copyright © 2011-2022 走看看