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
- Follow steps at https://update.angular.io/
ng update @angular/core
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
- fix(@schematics/update): support upper unbounded ranges Fixes: angular/angular-cli#10621 — committed to angular/devkit by clydin 6 years ago
- fix(@schematics/update): support upper unbounded ranges Fixes: angular/angular-cli#10621 — committed to angular/devkit by clydin 6 years ago
- at step 4 of https://github.com/angular/angular-cli/issues/10621#issuecomment-388630295 — committed to yogeshgadge/ngx-cbp-theme by yogeshgadge 6 years ago
- fix(@schematics/update): support upper unbounded ranges Fixes: angular/angular-cli#10621 — committed to angular/angular-cli by clydin 6 years ago
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:
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:
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 runingng update
alone first. This seems to update the core (including CLI) but doesn’t touch the angular-cli.json file. Then, upon runningng 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:Doing
ng update --all
isn’t doing its job either:I updated the cli first with
ng update @angular/cli
. Runningng update @angular/core
after that gives me the errorInvalid range: ">=4.3.0||>5.0.0"
.try
ng update --all --force
but evenng update
seems still in beta step or out of scopeI 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 resultBut If I run
ng update @angular/core
, I getInvalid 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:
My steps:
$ ng update
$ ng update --all
$ ng update @angular/core
$ ng update @angular/compiler
$ npm install @angular/compiler
-> the compiler was installed, but the version was5.2.0
$ ng update core
-> worked fine, no messages this timeThen, just to be sure, run
$ ng update
again, and got: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: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:ng update @angular/core
ng update @angular/material
I also needed to
ng update @angular/cli
Thanks @scharris
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.
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:
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.5And 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:
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 nological
(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.
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.
“Manually” means that you should update packages using “npm install” instead of “ng update”, like this:
I had to manually add the 6.0.0 to all angular components and 2.7.2 to typescript. then it worked.
Yeah, @scharris and @manuelescamilla , that method causes this problem: https://github.com/angular/angular-cli/issues/10664
Same here:
Invalid range ">2.4.2"