angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng update @angular/core fails

Open markgoho-EDT opened this issue 8 years ago • 83 comments

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"

markgoho-EDT avatar May 04 '18 00:05 markgoho-EDT

This is how I make it work.

My Environment:

Angular CLI Global : 6.0.0, Local: 1.7.4, Angular: 5.2, Typescript: 2.5.3

Note: To enable ng Update you need to install Angular CLI 6.0 first npm install -g @angular/cli or npm install @angular/cli

  1. ng update //update Angular Package core/common/complier... to 6.0.0

  2. ng update @angular/cli //change angular-cli.json to angular.json

optional if you have angular-material 5.4.2, ngx-translate 9.1.1, ng-bootstrap/ng-bootstrap 1.1.1:

  1. ng update @angular/material //upgrade to 6.0.1

  2. npm install @ngx-translate/[email protected] --save //upgrade ngX translate to 10.0.1 for Angular 6

5 npm install --save @ng-bootstrap/[email protected] //for ng-bootstrap

If you use Observable and get the error:

ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'. node_modules/rxjs/observable/of.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/observable/of'.

Change: import { Observable } from "rxjs/Observable"; import { of } from 'rxjs/observable/of';

To

import { Observable, of } from "rxjs";

RyanYizhaoHuang avatar May 08 '18 13:05 RyanYizhaoHuang

I finally got mine to work by doing the following: Step 1: Run npm ls --depth=1 to see if there is more than one version of webpack.

Step 2: If so, then npm uninstall webpack

Step 3: delete all of the other webpack- related folders in your node_modules directory. It is unnecessary to delete the entire node_modules directory.

Step 4: Run npm install @angular-devkit/build-angular@latest . The @angular-devkit builds contain their own copy of webpack.

Step 5: Ensure that your webpack dependencies are met. You shouldn't see any errors in your console related to webpack not being installed.

bluefire2121 avatar May 08 '18 17:05 bluefire2121

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

Bjeaurn avatar May 08 '18 17:05 Bjeaurn

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 [email protected] 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.

keefmarshall avatar May 08 '18 17:05 keefmarshall

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.

Bjeaurn avatar May 08 '18 18:05 Bjeaurn

@Bjeaurn yes 👍 Thank you. Updated.

bluefire2121 avatar May 08 '18 18:05 bluefire2121

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.

scharris avatar May 08 '18 23:05 scharris

Thanks @scharris screenshot 2018-05-08 22 52 49

manuelescamilla avatar May 09 '18 02:05 manuelescamilla

Yeah, @scharris and @manuelescamilla , that method causes this problem: https://github.com/angular/angular-cli/issues/10664

KissBalazs avatar May 09 '18 07:05 KissBalazs

No, it doesn't work for me.

when i call 'ng build' theres always the error:

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

bbuehrer avatar May 09 '18 11:05 bbuehrer

@bbuehrer : See @tolvaly's comment above, typescript 2.8 is really not supported so you have to install a typescript in that range. I chose 2.7.2 and that worked for me. "npm install [email protected]" and also with -g option.

scharris avatar May 09 '18 11:05 scharris

Downgrading to 2.7.2. breaks a lot of @angular imports with no apparent reason. Using 2.8.3, the imports work but the compiler fails and nothing is usable. Waiting for a fix, I don't know what to do. I already tried to uninstall the whole node_modules folder and start from scratch and the behaviour is the same. I tried verifying my package configuration through npm-check and everything is ok.

isametal88 avatar May 09 '18 11:05 isametal88

When i downgrade to typescript 2.7.2 and use angular/cli 6.0.0 then i have many errors with rxjs/Subscription and rxjs/Observable. My rxjs version is 6.1.0

bbuehrer avatar May 09 '18 11:05 bbuehrer

@bbuehrer, are you using the new import points for rxjs 6? They are changed (much simplified) so that could just be a legit compile error until imports are adjusted or the rxjs-compat package is added.

scharris avatar May 09 '18 11:05 scharris

ok i added the rxjs-compat package and it worked

bbuehrer avatar May 09 '18 11:05 bbuehrer

how can I find out if a new typescript version is compatible with angular/cli?

bbuehrer avatar May 09 '18 12:05 bbuehrer

I installed typescript 2.7.2 as soon as I got that error, and then proceeded ok.

npm install [email protected]

StrangeCargo74 avatar May 09 '18 13:05 StrangeCargo74

None of the mentioned solutions helped me because even though I had installed typescript 2.7.2, I had typescript ^2.8.3 in devDependecies. When I changed it to 2.7.2 everything worked correctly. So if you are as stupid as I am, check your package.json, install isn't enough in that case.

lakerko avatar May 09 '18 17:05 lakerko

Am I the only one that is facing the imports issue downgrading to 2.7.2.? What am I doing wrong? I checked my node_modules, tyescript is 2.7.2 as expected, but none of the imports of classes of angular work anymore. Anyway, should I expect a fix about this problem or it's gonna take a long time?

isametal88 avatar May 09 '18 17:05 isametal88

@isametal88 did you try to delete node_modules nad package-lock,json and run npm install again?

lakerko avatar May 09 '18 17:05 lakerko