Bower在生产中加载devDependencies?

时间:2014-03-03 19:22:03

标签: javascript angularjs leaflet bower

短版

我的项目需要angular-leaflet,而angular-leaflet有long list of devDependencies,包括jQuery 2.我不想要jQuery 2 - 我想要jQuery 1.x.如何让bower忽略angular-leaflet的devDependencies并让我使用jQuery 1?

长版

我正在使用凉亭1.2.8。这是一个最小的bower.json,它为我重现了这个问题:

{
  "name": "bower-test",
  "dependencies": {
    "jquery": "1.x",
    "angular": "1.2.x",
    "angular-leaflet": "0.7.x"
  }
}

运行bower install会导致以下错误:

Unable to find a suitable version for jquery, please choose one:
    1) jquery#1.x which resolved to 1.11.0 and has bower-test as dependants
    2) jquery#2.1.0 which resolved to 2.1.0 and has angular-leaflet#0.7.5 as dependants
    3) jquery#>= 1.9.0 which resolved to 2.1.0 and has bootstrap#3.0.3 as dependants

至少,我希望bower install --production忽略angular-leaflet中的devDependencies。但这是结果(与上面相同):

Unable to find a suitable version for jquery, please choose one:
    1) jquery#1.x which resolved to 1.11.0 and has bower-test as dependants
    2) jquery#2.1.0 which resolved to 2.1.0 and has angular-leaflet#0.7.5 as dependants
    3) jquery#>= 1.9.0 which resolved to 2.1.0 and has bootstrap#3.0.3 as dependants

为什么凉亭不会忽视角度传单的devDependencies?有没有办法让它这样做?

1 个答案:

答案 0 :(得分:4)

我认为您正在寻找的解决方案是resolutions的{​​{1}}部分 关于你bower.json的{​​{1}}为什么被分析的原因我不清楚。

devDependencies

这可能与dependencies略有不同,因为{ "name": "bower-test", "dependencies": { "jquery": "1.x", "angular": "1.2.x", "angular-leaflet": "0.7.x" }, "resolutions": { "jquery": "1.x" } } 包括npm,除非指定bower install xyzdevDependencies参数,但即使它已被指定,它似乎也没有传递给-p - 也许这是一个错误。

更新:问题似乎与使用--production的此特定程序包/设置有关。其他组件没有此问题。例如,dependencies只提取angular-leaflet,而不是bower install webmaker-analytics,即使它已列在此包devDependencies中。