我有一个bower.json文件
{
"name": "example-project",
"private": true,
"dependencies": {
"angular": "1.2.14",
"angular-scenario": "1.2.14",
"angular-resource": "1.2.14",
"angular-ui-router": "0.2.10",
"angular-strap": "2.0.0"
}
}
当我运行grunt
(使用 grunt-bowercopy 或 grunt-bower-task )时,我收到错误Fatal error: Unable to find suitable version for angular
当我运行bower install
时,它说它不知道要使用哪个版本的角度:
Unable to find a suitable version for angular, please choose one:
1) angular#1.2.14 which resolved to 1.2.14 and is required by angular-scenario#1.2.14, example-project
2) angular#>= 1.0.8 which resolved to 1.2.16 and is required by angular-ui-router#0.2.10
3) angular#~1.2.10 which resolved to 1.2.16 and is required by angular-strap#2.0.0
Prefix the choice with ! to persist it to bower.json
这就解释了为什么grunt失败了 - 它具有传递依赖性,并且不知道选择哪一个。所以我选择1(!1
来坚持)。现在我的bower.json看起来像这样:
{
"name": "example-project",
"private": true,
"dependencies": {
"angular": "1.2.14",
"angular-scenario": "1.2.14",
"angular-resource": "1.2.14",
"angular-ui-router": "0.2.10",
"angular-strap": "2.0.0"
},
"resolutions": {
"angular": "1.2.14"
}
}
甜!我再次运行bower install
。这一次它成功但删除了"决议"部分。现在它对我来说没有解决方案,但我的同事会得到同样的错误,并且必须经历相同的过程。
为什么这样做?有没有办法阻止它发生?
-Update -
这似乎是一个错误。请参阅凉亭问题https://github.com/bower/bower/issues/1061和https://github.com/bower/bower/issues/1272。希望这个问题能得到一些关注并得到解决。
答案 0 :(得分:1)
升级到Bower 1.4.0或更高版本,以解决此问题。
上一个答案: edeustace建议的解决方法(参见https://github.com/bower/bower/issues/1061)是为您的构建添加一个脚本(grunt,gulp等),它会在运行bower之后重置解决方案。这是一个丑陋的解决方案,但应该解决问题,直到问题得到解决。