Tim
Tim

Reputation: 1685

Error when upgrading to Angular Material 6.0.0

I am trying to follow the steps in the Angular update guide, but I'm running into a problem. Here is what I have done:

npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli

The above run without error (although there are some warnings), but ng update does not actually change the configuration files unless I run it a second time. After the second time everything looks okay.

ng update @angular/core

This runs okay, but complains (WARN) about @angular/[email protected].

ng update @angular/material

This produces:

Package "@angular/flex-layout" has an incompatible peer dependency to "@angular/cdk" (requires "^5.0.0", would install "6.0.0"). Incompatible peer dependencies found. See above.

So at that point I changed my package.json so that flex-layout is at version ^6.0.0-beta.15 and then run:

npm update @angular/flex-layout

Then I again tried to run

ng update @angular/material

and here is the output:

Updating package.json with dependency @angular/material-moment-adapter @ "6.0.0" (was "5.2.5")...
    Updating package.json with dependency @angular/cdk @ "6.0.0" (was "5.2.5")...
    Updating package.json with dependency @angular/material @ "6.0.0" (was "5.2.5")...
UPDATE package.json (1975 bytes)
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@>=0.9 <2 || ^2.1.0-beta || ^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

updated 3 packages in 15.415s
CREATE angular_material_schematics-36I3g7/collection.json (1251 bytes)
CREATE angular_material_schematics-36I3g7/migration.json (644 bytes)
CREATE angular_material_schematics-36I3g7/dashboard/index.js (1334 bytes)
CREATE angular_material_schematics-36I3g7/dashboard/index.js.map (879 bytes)
CREATE angular_material_schematics-36I3g7/dashboard/schema.js (111 bytes)
CREATE angular_material_schematics-36I3g7/dashboard/schema.js.map (135 bytes)
CREATE angular_material_schematics-36I3g7/dashboard/schema.json (2517 bytes)
...
lots of CREATE statements
...
CREATE angular_material_schematics-36I3g7/utils/devkit-utils/route-utils.js (3478 bytes)
CREATE angular_material_schematics-36I3g7/utils/devkit-utils/route-utils.js.map (2796 bytes)
CREATE angular_material_schematics-36I3g7/utils/devkit-utils/validation.js (663 bytes)
CREATE angular_material_schematics-36I3g7/utils/devkit-utils/validation.js.map (397 bytes)
npm WARN @angular/[email protected] requires a peer of @angular/cdk@>=6.0.0-beta.0 <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@>=0.9 <2 || ^2.1.0-beta || ^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/[email protected]
+ @angular/[email protected]
updated 2 packages in 15.846s
C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\util\hostReportError.js:9
    setTimeout(function () { throw err; });
                             ^

TypeError: Configuration.parseConfigFile is not a function
    at _loadConfiguration (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\@angular-devkit\schematics\tasks\tslint-fix\executor.js:16:30)
    at Observable.rxjs_1.Observable.obs [as _subscribe] (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\@angular-devkit\schematics\tasks\tslint-fix\executor.js:111:28)
    at Observable.subscribe (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\Observable.js:162:69)
    at C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\util\subscribeToResult.js:7:45)
    at MergeMapSubscriber._innerSub (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\operators\mergeMap.js:132:38)
    at MergeMapSubscriber._tryNext (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\operators\mergeMap.js:129:14)
    at MergeMapSubscriber._next (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\operators\mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\Subscriber.js:103:18)
    at C:\Users\Documents\NetBeansProjects\Frontend\node_modules\rxjs\internal\util\subscribeToPromise.js:7:24

Any ideas on what I am doing wrong or how to get around this error? Thanks!

Upvotes: 4

Views: 5400

Answers (3)

Brox Huang
Brox Huang

Reputation: 1

If you have tslint or codelyzer installed, make sure you upgrade them to the latest version before you run ng update @angular/material.

Upvotes: 0

ricardo_8990
ricardo_8990

Reputation: 81

In my case, before doing: ng update @angular/material

I first did: npm uninstall @angular/flex-layout

Then, I could successfully install angular material.

Upvotes: 0

diopside
diopside

Reputation: 3062

You may have more issues than just this, but I suspect the errors you are getting about rxjs at the bottom of your posted code are because the 6.0.0 version of rxjs simplified import paths by removing deep imports. It's a welcome change, but also, unfortunately, a breaking one.

All the operators are now in

 import { map, reduce, /* etc... */) } from 'rxjs/operators'

In the past, you had to import them individually from their respective directories.

And the common classes like subjects, observables, subscriptions, etc. are in

import { Observable, Subscription, BehaviorSubject, /* etc... */) } from 'rxjs'

They also released this which helps with the upgrade - https://www.npmjs.com/package/rxjs-compat

If any of your dependencies depend on the older version of rxjs, you may want to wait to upgrade or fix them yourself

Upvotes: 1

Related Questions