将AngularJS从1.5.0更新到1.5.8

时间:2017-03-28 10:38:03

标签: javascript angularjs bower

我有以下bower.json文件:

{  
  "private": true,
  "dependencies": {
    "angular": "~1.5.0",
    "angular-mocks": "^1.5.7",
    "bootstrap": "^3.3.6",
    "bootstrap-rtl": "^3.4.0",
    "font-awesome": "^4.6.3",
    "moment": "^2.13.0",
    "angular-animate": "^1.5.6",
    "angular-sanitize": "^1.5.6",
    "angular-ui-router": "~0.2.15",
    "angular-translate": "^2.11.0",
    "angular-touch": "^1.5.7",
    "angular-messages": "^1.5.6",
    "angular-cookies": "^1.5.8",
    "angular-ui-grid": "^3.1.1",
    "angular-ui-sortable": "^0.14.2",
    "angular-bootstrap-affix": "^0.2.2",
    "theia-sticky-sidebar": "^1.4.0",
    "angular-ui-router-title": "^0.0.4",
    "angularjs-slider": "^4.0.2",
    "angular-fcsa-number": "^1.5.3",
    "angularPrint": "angular-print#^0.3.8",
    "ng-virtual-keyboard": "^0.3.0",
    "keyboard": "^1.26.1",
    "angular-spinner": "^0.8.1",
    "ng-ip-address": "^1.1.10",
    "file-saver": "^1.3.2",
    "ng-iban": "^1.1.0",
    "pdfmake": "^0.1.20",
    "ng-device-detector": "^3.0.1",
    "checklist-model": "^0.10.0",
    "angular-dynamic-number": "^2.1.1",
    "ng-file-upload": "^12.2.13",
    "ng-file-upload-shim": "^12.2.13",
    "angular-ui-select": "^0.19.6",
    "angular-dragula": "^1.2.8",
    "angular-drag-and-drop-lists": "^2.0.0",
    "angular-slick-carousel": "^3.1.7",
    "angular-slick": "^0.2.1",
    "drag-drop-webkit-mobile": "^1.2.0",
    "iban": "^0.0.8",
    "highcharts": "^5.0.9"
  }
}

我想只将AngularJS更新为版本1.5.8。在没有任何头痛的情况下进行此更新的最佳方法是什么?我尝试安装bower install angular#1.5.8 --save,但当其他团队成员输入bower-update时,他们的整个项目都因为许多软件包已更新而崩溃。 任何明智的想法如何只更新AngularJS?

2 个答案:

答案 0 :(得分:4)

尝试"angular": "1.5.8",然后运行bower update而不是bower-update。您可能会在所有依赖项上切换到波形符~,以确保只更新次要版本。请注意,angular-mocks与AngularJS版本不对应。

  

用最简单的术语来说,代字号与最新的次要版本相匹配   (中间数字)。 ~1.2.3将匹配所有1.2.x版本,但会   错过1.3.0。

     另一方面,插入符号更放松。它会更新你   最新的主要版本(第一个数字)。 ^ 1.2.3将匹配   任何1.x.x版本,包括1.3.0,但将在2.0.0推迟。

{
    "private": true,
    "dependencies": {
        "angular": "1.5.8",
        "angular-mocks": "~1.5.7",
        "bootstrap": "~3.3.6",
        "bootstrap-rtl": "~3.4.0",
        "font-awesome": "~4.6.3",
        "moment": "~2.13.0",
        "angular-animate": "~1.5.6",
        "angular-sanitize": "~1.5.6",
        "angular-ui-router": "~0.2.15",
        "angular-translate": "~2.11.0",
        "angular-touch": "~1.5.7",
        "angular-messages": "~1.5.6",
        "angular-cookies": "~1.5.8",
        "angular-ui-grid": "~3.1.1",
        "angular-ui-sortable": "~0.14.2",
        "angular-bootstrap-affix": "~0.2.2",
        "theia-sticky-sidebar": "~1.4.0",
        "angular-ui-router-title": "~0.0.4",
        "angularjs-slider": "~4.0.2",
        "angular-fcsa-number": "~1.5.3",
        "angularPrint": "angular-print#~0.3.8",
        "ng-virtual-keyboard": "~0.3.0",
        "keyboard": "~1.26.1",
        "angular-spinner": "~0.8.1",
        "ng-ip-address": "~1.1.10",
        "file-saver": "~1.3.2",
        "ng-iban": "~1.1.0",
        "pdfmake": "~0.1.20",
        "ng-device-detector": "~3.0.1",
        "checklist-model": "~0.10.0",
        "angular-dynamic-number": "~2.1.1",
        "ng-file-upload": "~12.2.13",
        "ng-file-upload-shim": "~12.2.13",
        "angular-ui-select": "~0.19.6",
        "angular-dragula": "~1.2.8",
        "angular-drag-and-drop-lists": "~2.0.0",
        "angular-slick-carousel": "~3.1.7",
        "angular-slick": "~0.2.1",
        "drag-drop-webkit-mobile": "~1.2.0",
        "iban": "~0.0.8",
        "highcharts": "~5.0.9"
    }
}

答案 1 :(得分:2)

只有更新角度包才能在本地运行,但是当需要设置新项目并且想要安装依赖项时,您将以任何方式遇到此问题。我建议您根据需要设置依赖项,并确保不允许偏离您不想安装的版本。我将添加一些关于如何解释版本号的信息。

使用bower update <package_name>只会将该软件包更新为bower.json

中列出的版本

假设版本号如下:1.5.0。 每个数字都有一个均值,1是主要版本,5是次要版本,0是补丁号。就像这个major.minor.patch

一样

插入符号(^)表示您无法更改主要版本,但您可以更改次要版本和修补程序版本。因此^1.5.0的范围可以是1.5.0,但不包括2.0.0。因此,由于您拥有^1.5.0,因此在您的业务中,Angular将更新为最新的非主要版本更改1.6.3

代字号(~)表示仅修补程序版本更改(如果修补程序未在版本中指定,则为次要版本)

在此处详细了解:semver