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"
What I was doing:
- Follow "Before updating guide" from https://update.angular.io/
- Then set a typescript package version to 2.7.2 (yarn upgrade [email protected])
- yarn add global @angular/cli
- ng update @angular/cli
- yarn add @angular/cli
- Then continue following the guide
- ??????
- profit
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 ...
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.
same problem with 6.0.2 what is going on. `WARNING in ./node_modules/ng-http-loader/node_modules/@angular/core/esm2015/core.js 5354:15-36 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/ng-http-loader/node_modules/@angular/core/esm2015/core.js 5370:15-102 Critical dependency: the request of a dependency is an expression`
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.
@chriscurnow well. for me to update the angular from 5 to 6 I only needed this thread, ng-update guide and one day)
I couldn't use ng update @angular/core to upgrade to 6.0.2 (because of the non-sense "Invalid range..." error message). Then @angular/cli 6.0.3 has been released. After updating to @angular/cli 6.0.3 all ng update ... command worked well!
@tolvaly How do you "1. Manually update the angular packages to 6.0"? I tried "ng update @angular/[email protected]" but (after waiting 10 minutes) I get the same error.
@tolvaly How do you "1. Manually update the angular packages to 6.0"? I tried "ng update @angular/[email protected]" 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/[email protected] --save
npm install @angular/[email protected] --save
etc...
@alberthendriks How do you "1. Manually update the angular packages to 6.0"? I tried "ng update @angular/[email protected]" 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
As for many others - after upgrading to angular 6 package.json held fixed "6.0.0" version. Manually switching it to "^6.0.0" and executing npm install @angular/{core,forms,...,router} succesfully updates packages
Running below should help to update your dependencies to latest version.
npm i -g npm-check-updates
ncu -u
npm install
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 [email protected]
I also needed to install angular-devkit/build-angular as dev dependency npm install --save-dev @angular-devkit/build-angular
This solved my problem.
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 <3.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 <3.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 have facing incompatible peer dependency issues when i ran the command ng update @angular/core to update the core library of the existing angular project.
Package "angulartics2" has an incompatible peer dependency to "@angular/router" (requires ">=7.0.0-rc.0 <8.0.0||>=4.4.0 <=6.0.0", would install "6.0.5").
Package "codelyzer" has an incompatible peer dependency to "@angular/compiler" (requires ">=5.0.0-rc.0 <6.0.0||>=2.3.1 <3.0.0||>=4.0.0-beta <5.0.0", would install "6.0.5").
can some one help on this
@ZeeshanQurban From the message it seems that both of those libraries are specifically disallowing the 6.x.x version range.
I'm not personally using these, but from what I can see:
For angulartics2 it looks like they moved to support Angular 6.x when they released version 6 of the package: https://github.com/angulartics/angulartics2/releases/tag/v6.0.0
For codelyzer it seems they should be supporting Angular 6.x starting with 4.2.1: https://github.com/mgechev/codelyzer/commit/3112b38607f56002106b9039619693193a134eac
I have the same issue with it.
ng update @angular/core
Package "ngx-bootstrap" has an incompatible peer dependency to "@angular/forms" (requires ">=7.0.0-rc.0 <8.0.0||6.0.1", would install "6.0.7"). Incompatible peer dependencies found. See above.
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/router": "^6.0.0", "@auth0/angular-jwt": "^2.0.0", "alertifyjs": "^1.11.1", "bootstrap": "^4.1.1", "bootswatch": "^4.1.1", "core-js": "^2.5.4", "font-awesome": "^4.7.0", "hammerjs": "^2.0.8", "jquery": "^1.12.4", "ng2-file-upload": "^1.3.0", "ngx-bootstrap": "^3.0.0", "ngx-gallery": "^5.3.2", "popper.js": "^1.14.3", "rxjs": "^6.2.1", "time-ago-pipe": "^1.3.2", "underscore": "^1.9.1", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.6.1", "@angular/cli": "^6.0.8", "@angular/compiler-cli": "^6.0.0", "@angular/language-service": "^6.0.0", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "@types/underscore": "^1.8.8", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~1.4.2", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.3.0", "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "~2.7.2" }
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)
> [email protected] 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
> [email protected] 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
> [email protected] 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 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.
npm install [email protected] (or the version you need) then ng update @angular/core worked for me Good luck guys