bower入门

安装
安装bower需要先安装nodejs
安装命令 $ npm install -g bower

安装包
通过$ bower install [<options>]安装软件包,默认会安装到 bower_components/目录.
另外,可以通过配置文件bower.json一次安装所有软件包
通过$ bower init一路回车, 创建bower.json文件,bower.json内容如下

{
  "name": "bower-tuition",
  "authors": [
    "aoping <1216791584@qq.com>"
  ],
  "description": "",
  "main": "",
  "license": "MIT",
  "homepage": "",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ]
}

添加

"dependencies": {
  }

到上述文件,如

{
  "name": "bower-tuition",
  "authors": [
    "aoping <1216791584@qq.com>"
  ],
  "description": "",
  "main": "",
  "license": "MIT",
  "homepage": "",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "bootstrap": "^3.3.7"
  }
}

执行bower install就可以下载dependencies里的软件包了

bower常用命令

$ bower help <command> 显示关于Bower的帮助信息
$ bower init 创建bower.json文件
$ bower install [<options>] 安装包
$ bower update <name> [<name> ..] [<options>] 更新包
$ bower uninstall <name> [<name> ..] [<options>] 卸载包

.bowerrc

.bowerrc是bower的配置文件

{
  "analytics": true,
  "cwd": "~/.my-project",//当前目录
  "directory": "bower_components",//软件包安装的目录,默认是bower_components
  "registry": "https://bower.herokuapp.com",
  "shorthand-resolver": "git://github.com//.git",
  "proxy": "http://proxy.local",
  "https-proxy": "https://proxy.local",
  "ca": "/var/certificate.pem",
  "color": true,
  "timeout": 60000,
  "strict-ssl": true,
  "storage": {
    "packages" : "~/.bower/packages",
    "registry" : "~/.bower/registry",
    "links" : "~/.bower/links"
  },
  "interactive": true,
  "resolvers": [
    "mercurial-bower-resolver"
  ],
  "shallowCloneHosts": [
    "myGitHost.example.com"
  ],
  "scripts": {//三个钩子
    "preinstall": "",
    "postinstall": "",
    "preuninstall": ""
  },
  "ignoredDependencies": [
    "jquery"   
  ]
}

常见问题

  1. bower ENOINT Register requires an interactive shell

如果您使用的是windows,请换用WINDOW的cmd来输入命令试试
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值