尝试在项目中更新Angular CLI版本时看到错误

时间:2018-09-16 10:55:18

标签: angular6 angular-cli-v6

我的项目在package.json中具有以下依赖关系。

"dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/cdk": "^6.1.0",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/material": "^6.1.0",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "core-js": "^2.4.1",
    "json-server": "^0.12.1",
    "moment": "^2.22.1",
    "rxjs": "^6.2.0",
    "rxjs-compat": "^6.2.0",
    "zone.js": "^0.8.26"
  }

我想使用版本6.1.0,所以我将package.json更新为以下版本

"dependencies": {
    "@angular/animations": "^6.1.0",
    "@angular/cdk": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/material": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.0.3",
    "core-js": "^2.5.4",
    "json-server": "^0.12.1",
    "moment": "^2.22.1",
    "rxjs": "^6.2.0",
    "rxjs-compat": "^6.2.0",
    "zone.js": "^0.8.26"
  }

但是我注意到来自IDE The installed version didn't match version range的错误导致输入很少。我以为如果在这里指定新版本,则这些版本将自动更新。不是这样吗如何升级依赖项?

我在全局(版本ng)和本地(版本6.2.1)都安装了6.0.7。它们的版本不同。我想将本地更新为更高版本,并执行此操作,我想只更新package.json中的条目。

1 个答案:

答案 0 :(得分:0)

我认为正确的方法是运行ng update,并且应该列出所有需要更新的软件包。当我在本地和全局安装了ng时,如果我只是ng update,则会看到消息“。

为确保我使用本地版本进行更新,我使用npx ng update列出了需要更新的模块,并使用npx ng update -all来更新所有模块。