angular-cli: ng update @angular/core fails

Versions

Angular CLI: 6.0.0
Node: 8.9.1
OS: win32 x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.6.0
@angular-devkit/core         0.6.0
@angular-devkit/schematics   0.6.0
@angular/cli                 6.0.0
@schematics/angular          0.6.0
@schematics/update           0.6.0
rxjs                         5.5.10
typescript                   2.6.2

Repro steps

Observed behavior

Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.6.2")
Invalid range: ">=4.3.0"

Desired behavior

I would expect this to work properly.

Mention any other details that might be useful (optional)

I tried to manually update the compiler-cli and run the update function again and got this:

$ ng update @angular/core
Invalid range: ">=4.3.0"

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 104
  • Comments: 83 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry for beeing so negative and off topic, but what’s the point for Google to provide a new ng update command supposed to ease things if we need 58 comments in a an issue and 6 steps, to go from 6.0.0 to 6.0.1 in the end? I gave up, I will update this later when tools will be less cumbersome to use.

This should have been checked before angular 6.0.0 was released. Now I have to downgrade everything.

Workaround:

  1. Update manually the angular packages to 6.0.0
  2. ng update rxjs
  3. ng update angular/core
  4. ng update angular/material
  5. if ng update installs typescript 2.8.3 you have to install typescript version 2.7.2. angular compiler doesn;t work with 2.8.3

Hey Everyone, After alot of research, I have come up with following solution and got success in updating my local project to Angular 6.0.1:

  1. npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@‘6.0.1’
  2. ng update rxjs
  3. npm install rxjs@6 rxjs-compat@6 --save
  4. ng update angular/core
  5. ng update angular/material
  6. npm install typescript@‘>=2.7.0 <2.8.0’

It’s always such a pain in the a** to update node packages, ffs.

Same : Invalid range: “>=2.3.1 ❤️.0.0||>=4.0.0”

Temporary workaround seems to be skipping the ng update @angular/cli step and instead runing ng update alone first. This seems to update the core (including CLI) but doesn’t touch the angular-cli.json file. Then, upon running ng update @angular/cli it does that upgrade process.

@markgoho-EDT, the ng update itself doesn’t do anything else as showing the packages that have to be updated:

ng update
    We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/core                      5.0.5 -> 6.0.0           ng update @angular/core
      @angular/material                  5.2.0 -> 6.0.0           ng update @angular/material
      rxjs                               5.5.2 -> 6.1.0           ng update rxjs


    There might be additional packages that are outdated.
    Or run ng update --all to try to update all at the same time.

Doing ng update --all isn’t doing its job either:

ng update --all
                  Package "karma-jasmine-html-reporter" has a missing peer dependency of "jasmine" @ "^3.0.0".
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.8.3")
                  Package "@auth0/angular-jwt" has an incompatible peer dependency to "@angular/common" (requires "^4.4.6||^5.0.0", would install "6.0.0")
                  Package "ng2-pdf-viewer" has a missing peer dependency of "pdfjs-dist" @ "2.0.489".
Invalid range: ">=6.0.0-rc.0"

I updated the cli first with ng update @angular/cli. Running ng update @angular/core after that gives me the error Invalid range: ">=4.3.0||>5.0.0".

try ng update --all --force but even ng update seems still in beta step or out of scope

I know this is “closed” with a “fix” in place, but trying to ng update to 6.0.2 produces the same “invalid range” error. ng update is more of a problem that it’s solving at the moment.

If I run ng update I get this result

We analyzed your package.json, there are some packages to update:
Name                               Version                  Command to update
--------------------------------------------------------------------------------
@angular/core                      5.0.5 -> 6.0.0           ng update @angular/core
rxjs                               5.5.10 -> 6.1.0          ng update rxjs

But If I run ng update @angular/core , I get Invalid range: ">=2.0.0"

I was experiencing the same problem reported by @markgoho-EDT, with some changes I was able to fix it, bellow you can see my steps, maybe it will help someone else.

The error message: Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.6.2")

I was following along the steps from the https://update.angular.io page, but the above error poped when I was trying to run the ng update @angular/core bit.

What I have installed so far:

  • Angular CLI (local and global): 6.0.0
  • Typescript: 2.8.3

My steps:

$ ng update

  Name                               Version                  Command to update
 --------------------------------------------------------------------------------
  @angular/core                      5.2.10 -> 6.0.0          ng update @angular/core
  rxjs                               5.5.10 -> 6.1.0          ng update rxjs


There might be additional packages that are outdated.
Or run ng update --all to try to update all at the same time.

$ ng update --all

Package "karma-jasmine-html-reporter" has a missing peer dependency of "jasmine" @ "^3.0.0".
Package "@angular/platform-browser-dynamic" has a missing peer dependency of "@angular/compiler" @ "6.0.0".

$ ng update @angular/core

Package not installed: "@angular/compiler". Skipping.

$ ng update @angular/compiler

Package not installed: "@angular/compiler". Skipping.

$ npm install @angular/compiler -> the compiler was installed, but the version was 5.2.0

+ @angular/compiler@6.0.0
removed 7 packages and updated 1 package in 11.763s

$ ng update core -> worked fine, no messages this time

Then, just to be sure, run $ ng update again, and got:

We analyzed your package.json and everything seems to be in order. Good work!

This is what I’ve done, worked for me, maybe will work for someone else. I think the key step was installing the @angular/compiler again, to force its update.

Note: I’ve just started this project, so no big changes for me, my dev env was almost pristine.

My workaround: remove @angular/compiler-cli from package.json run ng update @angular/core npm i --save-dev @angular/compiler-cli@latest

seems to work 😄

For future reference. I got frustrated trying so many “solutions” with no avail so I decided to just run the following command.

$ ng update --all --force

It was a wild gamble and took a while to update but now everything is working and my project is up-to-date.

@IterationCorp - this doesn’t update your configuration files then, which means your karma, tslint and angular config won’t get updated at all.

@ray-kay I had a clean install of 6.0.0. When running ng update --all to try update to the 6.0.1, here is the error I have:

Package "karma-jasmine-html-reporter" has a missing peer dependency of "jasmine" @ ">=3".
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.8.3").
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.8.3")
Incompatible peer dependencies found. See above.

My package.json contains "typescript": "2.7.2" in devDependencies. That makes no sens to me.

Similar issues here. I just started a new Angular 6.0.0 project from CLI 6.0.0 a week ago. I could update angular-cli to version 6.0.1 but doing ng update @angular/core shows me Invalid range: “>=5.0.0”

I have typescript@2.7.2 and rxjs@6.0.1 installed

Anybody facing the same issue trying to update angular/core from 6.0.0 -> 6.0.1 ?

I have updated my project to @angular/cli 6.0.0 and typescript to version 2.8.3. Now with ‘ng build’ i have the following error:

ERROR in The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead.

What is the reason? What can i do?

Here’s the dependencies in my my package.json:

“dependencies”: { “@angular/animations”: “^6.0.0”, “@angular/common”: “^6.0.0”, “@angular/compiler”: “^6.0.0”, “@angular/core”: “^6.0.0”, “@angular/forms”: “^6.0.0”, “@angular/http”: “^6.0.0”, “@angular/platform-browser”: “^6.0.0”, “@angular/platform-browser-dynamic”: “^6.0.0”, “@angular/platform-server”: “^6.0.0”, “@angular/router”: “^6.0.0”, “@angular/service-worker”: “^6.0.0”, “@ng-idle/core”: “^2.0.0-beta.15”, “base64-arraybuffer”: “^0.1.5”, “core-js”: “^2.5.6”, “font-awesome”: “~4.7.0”, “intl”: “~1.2.5”, “lodash”: “^4.17.10”, “ng2-simple-timer”: “^1.3.3”, “ngx-cookie-service”: “^1.0.10”, “npm”: “^6.0.0”, “primeng”: “^5.2.6”, “primeng-extensions-wizard”: “~2.2.0”, “rxjs”: “^6.1.0”, “web-animations-js”: “~2.3.1”, “zone.js”: “^0.8.26” }, “devDependencies”: { “@angular-devkit/build-angular”: “~0.6.0”, “@angular/cli”: “^6.0.0”, “@angular/compiler-cli”: “^6.0.0”, “@types/jasmine”: “^2.8.7”, “@types/lodash”: “^4.14.108”, “@types/node”: “^10.0.4”, “codelyzer”: “^4.3.0”, “jasmine-core”: “~3.1.0”, “jasmine-spec-reporter”: “~4.2.1”, “karma”: “^2.0.2”, “karma-chrome-launcher”: “~2.2.0”, “karma-cli”: “~1.0.1”, “karma-coverage-istanbul-reporter”: “^1.4.2”, “karma-jasmine”: “^1.1.2”, “karma-jasmine-html-reporter”: “^1.0.0”, “protractor”: “^5.3.1”, “ts-node”: “^6.0.3”, “tslint”: “^5.10.0”, “typescript”: “^2.8.3” }

I tried following the steps @Rumsha001 laid out but was still having “Invalid range” failures at the ng update @angular/core step. Then I changed step 1 to use version ‘6.0.2’ and finally things worked. No guarantees this was the magic touch though … I tried many things tonight, in various orders, etc.

Overall, very frustrating, I’ve gotta say …

The main problem seems to be with ng update --all not doing its job properly. Following @Rumsha001 's approach seems to work well.

Just don’t forget the @s:

  1. ng update @angular/core
  2. ng update @angular/material

I also needed to ng update @angular/cli

It appears to be important to initially leave the local @angular/cli version at 1.7.4 (or whatever) and not 6.0.0. This is actually what the “npm install @angular/cli” in the update instructions did do for me, but it also gives a warning that the local one is at an older version that the global one which is at 6.0.0. That caused me to first try setting the local @angular/cli to 6.0.0 like the global one before continuing, but that lead to the range errors.

Starting over again from previous state (everything at 5.2) pulled from version control, I had luck by just ignoring that warning (so local @angular/cli was at 1.7.4 after the “ng update @angular/cli”), and was able to get through the install as described at update.angular.io.

Running below should help to update your dependencies to latest version.

npm i -g npm-check-updates
ncu -u
npm install

@alberthendriks How do you “1. Manually update the angular packages to 6.0”? I tried “ng update @angular/animations@6.0.3” but (after waiting 10 minutes) I get the same error.

Meanwhile I found out why updating doesn’t work with ng update. It’s because of 3rd-party libraries witch depends on angular. You have to find out witch of them is breaking your update, and you have to update them manually to the latest version witch support angular and rxjs 6. You have to analyse your package.json, check each dependency under “dependencies”. This is also a good opportunity to throw out old libraries witch aren’t used or maintained anymore!

Couple of example libraries that broke my update were:

  • @ angular/flex-layout; Currently latest version: 6.0.0-beta.15
  • ng2-signalr; Currently latest version: 6.0.0
  • @ ngx-translate/core; Currently latest version: 10.0.2
  • ngx-moment; Currently latest version: 2.0.0

Until today all of them released a new version supporting angular6, and today I managed to update my packages to angular 6.0.5 running ng update @angular/cli without any issue. I was using angular/cli version 6.0.5

And responding to your question, under manual update I mean, you have to change the version numbers in package.json manually and run npm install to update the outdated packages.

Be aware, when updating rxjs to 6 you should follow this guide

It certainly looks like ng update needs more work.

But people complaining here should have been around when Angular (2) was still in alpha. It was pretty hairy back then with breaking changes every couple of days sometimes.

That experience taught me it was worth sticking with Angular. It just gets better all the time. Sure a new feature like ng update might not work for everyone straight out of the box but I think we can all rest assured the engineers at Google will be working on it until they get it pretty well right.

Also remember updating from v5 to v6 is going to be a pretty huge task to accomplish with a single tool. After we have updated to v6, I’m sure the update process for future versions will be a whole lot better.

What I was doing:

  1. Follow “Before updating guide” from https://update.angular.io/
  2. Then set a typescript package version to 2.7.2 (yarn upgrade typecsript@2.7.2)
  3. yarn add global @angular/cli
  4. ng update @angular/cli
  5. yarn add @angular/cli
  6. Then continue following the guide
  7. ???
  8. profit

I just run npm update instead ng update and it updated Angular’s packages to 6.0.1 without any issues. Maybe an issue in the cli ng update dependency detection?

ok i added the rxjs-compat package and it worked

In regards to the Invalid range: xxx errors, I’ve taken a quick peek at the @angular-devkit/schematics repo to see where the error was thrown and what was actually happening.

The error is thrown at https://github.com/angular/devkit/blob/master/packages/schematics/update/update/index.ts#L41

If I look at the surrounding function, seems that it’s expecting semver versioned packages only, and no logical (by the lack of a better term?) versioning.

I would try to debug it further, but can’t seem to locate the compiled files in my project to tinker with it.

I also got: Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.8", would install "2.6.2")

I just fixed this by running npm install typescript@2.7.2 immediately after seeing the error.

I did subsequently get a heck of a lot of warnings and things that look like errors during the angualr/material update though it claimed to complete successfully.

@bluefire2121 Did you mean npm ls --depth=1 ?

ng update --all --force worked for me also.

@kobusbeets I can’t say it was a “wild gamble” though, not with a version control system.

npm install typescript@3.1.3 (or the version you need) then ng update @angular/core worked for me Good luck guys

I gotta say, the rabbit hole on this issue is a little nuts. I’m trying an ng update from 6.0.2 to 6.2.4, and I’ve chased through several missing packages that were apparently added in between those two versions. I started with @angular-devkit/build-angular, but then also hit clean-css, compression and dom-converter. I got stuck on the last two, because attempting to install either one states that the other one is missing. ng update is a big fat fail for me. There should be something to detect missing packages between versions, and install those as part of the ng update process. Otherwise, it’s faster to create a project from scratch and manually copy everything over.

cl-pur-w7-04:freeride.gitlab.io student$ ng update --all
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.0.1").
Incompatible peer dependencies found. See above.
cl-pur-w7-04:freeride.gitlab.io student$ ng update @angular/cli
    Updating package.json with dependency @angular/cli @ "6.1.2" (was "6.0.8")...
UPDATE package.json (1500 bytes)

> fsevents@1.2.4 install /Users/student/src/freeride.gitlab.io/node_modules/fsevents
> node install

[fsevents] Success: "/Users/student/src/freeride.gitlab.io/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> node-sass@4.9.0 install /Users/student/src/freeride.gitlab.io/node_modules/node-sass
> node scripts/install.js

Cached binary found at /Users/student/.npm/node-sass/4.9.0/darwin-x64-64_binding.node

> node-sass@4.9.0 postinstall /Users/student/src/freeride.gitlab.io/node_modules/node-sass
> node scripts/build.js

Binary found at /Users/student/src/freeride.gitlab.io/node_modules/node-sass/vendor/darwin-x64-64/binding.node
Testing binary
Binary is fine
added 1173 packages from 1293 contributors and audited 21839 packages in 40.852s
found 14 vulnerabilities (9 low, 5 high)
  run `npm audit fix` to fix them, or `npm audit` for details
cl-pur-w7-04:freeride.gitlab.io student$ ng serve
^C
cl-pur-w7-04:freeride.gitlab.io student$ ls -a
.			.git			angular.json		package.json		tslint.json
..			.gitignore		e2e			sketch
.DS_Store		.gitlab-ci.yml		node_modules		src
.editorconfig		README.md		package-lock.json	tsconfig.json
cl-pur-w7-04:freeride.gitlab.io student$ ng update --all
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.0.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.0.1").
Incompatible peer dependencies found. See above.
cl-pur-w7-04:freeride.gitlab.io student$ ng update
    We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/core                      6.0.3 -> 6.1.1           ng update @angular/core
      rxjs                               6.2.0 -> 6.2.2           ng update rxjs


    There might be additional packages that are outdated.
    Or run ng update --all to try to update all at the same time.

cl-pur-w7-04:freeride.gitlab.io student$ ng update --all
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.0.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.0.1").
Incompatible peer dependencies found. See above.
cl-pur-w7-04:freeride.gitlab.io student$ npm install
audited 21839 packages in 8.918s
found 14 vulnerabilities (9 low, 5 high)
  run `npm audit fix` to fix them, or `npm audit` for details
cl-pur-w7-04:freeride.gitlab.io student$ ng update --all
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.0.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=2.7.2 <2.10", would install "3.0.1").
Incompatible peer dependencies found. See above.
cl-pur-w7-04:freeride.gitlab.io student$

I could have faced incompatible peer dependency issues when i ran the command ng update @angular/core to update the core library of the existing angular project.

Issues

Package “@angular/cdk” has an incompatible peer dependency to “@angular/common” (requires “>=5.0.0-rc.0 <6.0.0||>=4.0.0 <5.0.0”, would install “6.0.0”). Package “codelyzer” has an incompatible peer dependency to “@angular/core” (requires “>=5.0.0-rc.0 <6.0.0||>=2.3.1 ❤️.0.0||>=4.0.0-beta <5.0.0”, would install “6.0.0”). Package “codelyzer” has an incompatible peer dependency to “@angular/compiler” (requires “>=5.0.0-rc.0 <6.0.0||>=2.3.1 ❤️.0.0||>=4.0.0-beta <5.0.0”, would install “6.0.0”).

in second time i used the following command to update the core library ng update --next but still there an issue.

issue had fix when i use the following command with --force flag, ng update @angular/core --next --force

now, my project library has been updated from version 4 to 6. Well done 😃

“dependencies”: { “@angular/animations”: “^6.0.0”, “@angular/cdk”: “^2.0.0-beta.8”, “@angular/common”: “^6.0.0”, “@angular/compiler”: “^6.0.0”, “@angular/core”: “^6.0.0”, “@angular/forms”: “^6.0.0”, “@angular/http”: “^6.0.0”, “@angular/material”: “^2.0.0-beta.8”, “@angular/platform-browser”: “^6.0.0”, “@angular/platform-browser-dynamic”: “^6.0.0”, “@angular/router”: “^6.0.0”, “core-js”: “^2.4.1”, “rxjs”: “^6.2.0”, “zone.js”: “^0.8.26”, “rxjs-compat”: “^6.0.0-rc.0” },

Good Luck !!!

I had a typescript version missmatch like many people (requires “>=2.7.2 <2.8”, would install “2.8.3”). My package.json contained typescript 2.7.2 but my package-lock.json contained typescript 2.9… I remove this entry from package-lock.json and i run npm install typescript@2.7.2

I also needed to install angular-devkit/build-angular as dev dependency npm install --save-dev @angular-devkit/build-angular

This solved my problem.

@tolvaly How do you “1. Manually update the angular packages to 6.0”? I tried “ng update @angular/animations@6.0.3” but (after waiting 10 minutes) I get the same error.

“Manually” means that you should update packages using “npm install” instead of “ng update”, like this:

npm install @angular/core@6.0.0 --save
npm install @angular/common@6.0.0 --save
etc...

I had to manually add the 6.0.0 to all angular components and 2.7.2 to typescript. then it worked.

Same here: Invalid range ">2.4.2"