在尝试为我的个人博客安装bootstrap#v4.0.0-alpha.5时遇到了一个奇怪的问题。
首先我尝试运行bower install bootstrap#v4.0.0-alpha.5
结果错误> zsh: no matches found: bootstrap#v4.0.0-alpha.5
然后我尝试运行bower install bootstrap --force-latest
请注意我还使用bower cache clear
再次运行此操作
如图所示安装最新稳定而非最新版本。
以下结果>
bower bootstrap#* not-cached https://github.com/twbs/bootstrap.git#*
bower bootstrap#* resolve https://github.com/twbs/bootstrap.git#*
bower bootstrap#* download https://github.com/twbs/bootstrap/archive/v3.3.7.tar.gz
bower bootstrap#* extract archive.tar.gz
bower bootstrap#* resolved https://github.com/twbs/bootstrap.git#3.3.7
bower jquery#1.9.1 - 3 not-cached https://github.com/jquery/jquery-dist.git#1.9.1 - 3
bower jquery#1.9.1 - 3 resolve https://github.com/jquery/jquery-dist.git#1.9.1 - 3
bower jquery#1.9.1 - 3 download https://github.com/jquery/jquery-dist/archive/3.1.1.tar.gz
bower jquery#1.9.1 - 3 extract archive.tar.gz
bower jquery#1.9.1 - 3 resolved https://github.com/jquery/jquery-dist.git#3.1.1
bower bootstrap#^3.3.7 install bootstrap#3.3.7
bower jquery#1.9.1 - 3 install jquery#3.1.1
bootstrap#3.3.7 bower_components/bootstrap
└── jquery#3.1.1
jquery#3.1.1 bower_components/jquery
我通过运行bower init
并在下方创建bower.json
并在项目根目录中运行bower install
来解决此问题。
我的bower.json
>
{
"name": "kimmohintikka",
"description": "",
"main": "index.js",
"authors": [
"HintikkaKimmo <hintikkakimmo@gmail.com>"
],
"license": "ISC",
"homepage": "",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "^4.0.0-alpha.5"
}
}
最后我的问题。这个问题是Bower还是引导alpha的命名方式,或者我不知道如何使用bower?当我运行bower安装时,它将首先安装我尝试安装的软件包。
请参阅下面的输出&gt;
2.7.11/envs/kimmohintikka) ➜ kimmohintikka git:(master) ✗ bower install
bower bootstrap#^4.0.0-alpha.5 not-cached https://github.com/twbs/bootstrap.git#^4.0.0-alpha.5
bower bootstrap#^4.0.0-alpha.5 resolve https://github.com/twbs/bootstrap.git#^4.0.0-alpha.5
bower bootstrap#^4.0.0-alpha.5 download https://github.com/twbs/bootstrap/archive/v4.0.0-alpha.5.tar.gz
bower bootstrap#^4.0.0-alpha.5 extract archive.tar.gz
bower bootstrap#^4.0.0-alpha.5 resolved https://github.com/twbs/bootstrap.git#4.0.0-alpha.5
bower tether#^1.3.7 not-cached https://github.com/HubSpot/tether.git#^1.3.7
bower tether#^1.3.7 resolve https://github.com/HubSpot/tether.git#^1.3.7
bower tether#^1.3.7 download https://github.com/HubSpot/tether/archive/v1.3.7.tar.gz
bower tether#^1.3.7 extract archive.tar.gz
bower tether#^1.3.7 resolved https://github.com/HubSpot/tether.git#1.3.7
bower bootstrap#^4.0.0-alpha.5 install bootstrap#4.0.0-alpha.5
bower tether#^1.3.7 install tether#1.3.7
bootstrap#4.0.0-alpha.5 bower_components/bootstrap
├── jquery#3.1.1
└── tether#1.3.7
tether#1.3.7 bower_components/tether
答案 0 :(得分:1)
经过一番研究,我们发现真正的罪魁祸首是zsh,详见:http://coderwall.com/p/nqckeq/zsh-bower-and-command-not-found
ZSH正在自己的议程中做一些事情,所以你可以通过添加这个别名bower =&#39; noglob bower&#39;来删除它对bower的全局设置。到您的〜/ .zshrc文件或使用命令&#34;引号&#34; bower install "bootstrap#v4.0.0-alpha.5"
D:\git\test>bower install bootstrap#v4.0.0-alpha.5
bower bootstrap#v4.0.0-alpha.5 not-cached https://github.com/twbs/bootstrap.git#v4.0.0-alpha.5
bower bootstrap#v4.0.0-alpha.5 resolve https://github.com/twbs/bootstrap.git#v4.0.0-alpha.5
bower bootstrap#v4.0.0-alpha.5 download https://github.com/twbs/bootstrap/archive/v4.0.0-alpha.5.tar.gz
bower bootstrap#v4.0.0-alpha.5 extract archive.tar.gz
bower bootstrap#v4.0.0-alpha.5 resolved https://github.com/twbs/bootstrap.git#4.0.0-alpha.5
bower jquery#1.9.1 - 3 cached https://github.com/jquery/jquery-dist.git#3.1.1
bower jquery#1.9.1 - 3 validate 3.1.1 against https://github.com/jquery/jquery-dist.git#1.9.1 - 3
bower tether#^1.3.7 not-cached https://github.com/HubSpot/tether.git#^1.3.7
bower tether#^1.3.7 resolve https://github.com/HubSpot/tether.git#^1.3.7
bower tether#^1.3.7 download https://github.com/HubSpot/tether/archive/v1.3.7.tar.gz
bower tether#^1.3.7 extract archive.tar.gz
bower tether#^1.3.7 resolved https://github.com/HubSpot/tether.git#1.3.7
bower bootstrap#v4.0.0-alpha.5 install bootstrap#4.0.0-alpha.5
bower jquery#1.9.1 - 3 install jquery#3.1.1
bower tether#^1.3.7 install tether#1.3.7
bootstrap#4.0.0-alpha.5 bower_components\bootstrap
├── jquery#3.1.1
└── tether#1.3.7
jquery#3.1.1 bower_components\jquery
tether#1.3.7 bower_components\tether
你的凉亭版本是什么?你有没有尝试更新它?
当你尝试时,你会得到什么:bower install bootstrap#^4.0.0-alpha.5
这会模拟你的bower.json
您还可以使用此命令获取引导程序的所有可用版本和预发布的列表:bower info bootstrap --verbose
以下是我从中获得的版本:
D:\git\test>bower info bootstrap --verbose
bower bootstrap#* cached https://github.com/twbs/bootstrap.git#3.3.7
bower bootstrap#* validate 3.3.7 against https://github.com/twbs/bootstrap.git#*
{
name: 'bootstrap',
description: 'The most popular front-end framework for developing responsive, mobile first projects on the web.',
keywords: [
'css',
'js',
'less',
'mobile-first',
'responsive',
'front-end',
'framework',
'web'
],
homepage: 'http://getbootstrap.com',
license: 'MIT',
moduleType: 'globals',
main: [
'less/bootstrap.less',
'dist/js/bootstrap.js'
],
ignore: [
'/.*',
'_config.yml',
'CNAME',
'composer.json',
'CONTRIBUTING.md',
'docs',
'js/tests',
'test-infra'
],
dependencies: {
jquery: '1.9.1 - 3'
},
version: '3.3.7'
}
Available versions:
- 4.0.0-alpha.5
- 4.0.0-alpha.4
- 4.0.0-alpha.3
- 4.0.0-alpha.2
- 4.0.0-alpha
- 3.3.7
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-rc1
- 3.0.0-rc.2
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
You can request info for a specific version with 'bower info bootstrap#<version>'