为什么bower会安装最新版本的软件包而不是我想要的软件包?

时间:2016-05-27 09:08:33

标签: bower bower-install

在bower.json中有这个

{
    "name": "test",
    "dependencies": {
        "jquery": "2.2.4",
        "html5shiv": "3.6.2"
    }
}

并正在运行

  

bower install

bower安装不是这个版本,而是最新版本(jquery 3.0.0-rc1& html5shiv 3.7.3)。为什么这样?我没有任何其他可能需要最新版本的依赖项。

这是凉亭安装日志

bower cached https://github.com/jquery/jquery-dist.git#2.2.4
bower验证2.2.4对https://github.com/jquery/jquery-dist.git#2.2.4
凉亭缓存https://github.com/aFarkas/html5shiv.git#3.6.2
bower验证3.6.2对https://github.com/aFarkas/html5shiv.git#3.6.2
凉亭安装jquery#2.2.4
凉亭安装html5shiv#3.6.2

jquery#2.2.4 bower_components \ jquery

html5shiv#3.6.2 bower_components \ html5shiv



对我而言,html5shiv的.bower.json看起来像这样很奇怪

{
  "name": "html5shiv",
  "version": "3.6.2",
  "main": [
    "dist/html5shiv.js"
  ],
  "ignore": [
    "**/.*",
    "composer.json",
    "test",
    "build",
    "src",
    "build.xml"
  ],
  "homepage": "https://github.com/aFarkas/html5shiv",
  "_release": "3.6.2",
  "_resolution": {
    "type": "version",
    "tag": "3.6.2",
    "commit": "f65f9b0d776ae3b88d4c7f0b27c64e384aee47aa"
  },
  "_source": "https://github.com/aFarkas/html5shiv.git",
  "_target": "3.6.2",
  "_originalSource": "html5shiv"
}

但是bower.json看起来像这样

{
  "name": "html5shiv",
  "version": "3.7.3",
  "main": [
    "dist/html5shiv.js"
  ],
  "ignore": [
    "**/.*",
    "composer.json",
    "test",
    "build",
    "src",
    "build.xml"
  ]
}

jQuery也一样。 .bower.json引用我想要的版本,但是bower.json引用了最新版本。就像我说的那样,source和dist文件来自最新版本。

1 个答案:

答案 0 :(得分:0)

你应该在版本之前使用# 例如

{ 
    "name": "test",
    "dependencies": {
        "jquery": "#2.2.4"    
    }
}

您可以找到more about bower here