Seeing error when I tried to update Angular CLI version in the project

147 views Asked by At

My project has the following dependencies in 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"
  }

I want to use version 6.1.0 so I updated the package.json to following

"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"
  }

But I notice an error from the IDE The installed version didn't match version range for few entries. I thought that if I specify new versions here then the versions will be automatically updated. Isn't that the case? How can I upgrade the dependencies?

I have ng installed both globally (version 6.2.1) and locally (version 6.0.7). Their versions are different. I want to update local to the higher version and to do this, I thought I'll just update entries in package.json.

1

There are 1 answers

0
Manu Chadha On BEST ANSWER

I suppose the correct way is to run ng update and that should list all the packages that need updating. As I have ng installed both locally and globally, if I just do ng update, I see message ``.

To be sure that I am updating using the local version, I use npx ng update to list the modules which need updating and use npx ng update -all to update all of them.