【问题标题】:Why does Bower remove my "resolutions" and how do I stop it为什么 Bower 会删除我的“决议”,我该如何阻止它
【发布时间】:2014-05-21 17:03:53
【问题描述】:

我有一个 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-bowercopygrunt-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。这次它成功了,但删除了“决议”部分。现在它只适用于没有解决方案的我,但我的同事会遇到同样的错误并且必须经历同样的过程。

为什么要这样做?有什么办法阻止它发生吗?

-更新-

这似乎是一个错误。请参阅凉亭问题 https://github.com/bower/bower/issues/1061https://github.com/bower/bower/issues/1272。希望这个问题会得到一些关注并得到解决。

【问题讨论】:

    标签: bower


    【解决方案1】:

    升级到 Bower 1.4.0 或更高版本已解决此问题。

    上一个答案: edeustace 建议的解决方法(请参阅https://github.com/bower/bower/issues/1061)是在您的构建(grunt、gulp 等)中添加一个脚本,以在运行 bower 后重置分辨率。这是一个丑陋的解决方案,但在问题得到解决之前应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-29
      • 1970-01-01
      • 2011-06-21
      • 2011-06-20
      • 2011-12-15
      • 2012-06-26
      • 1970-01-01
      相关资源
      最近更新 更多