升级到Angular Material 6.0.0时出错

时间:2018-05-04 16:45:23

标签: angular angular-material

我正在尝试按照Angular update guide中的步骤操作,但我遇到了问题。这就是我所做的:

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

以上运行没有错误(虽然有一些警告),但ng update实际上并没有更改配置文件,除非我第二次运行它。第二次之后,一切看起来还不错。

ng update @angular/core

这样运行正常,但抱怨(WARN)关于@ angular / flex-layout @ 5.0.0-beta.14。

ng update @angular/material

这会产生:

  

Package" @ angular / flex-layout"具有不兼容的对等依赖关系   " @角蛋白/ cdk" (需要" ^ 5.0.0",将安装" 6.0.0")。   找到了不兼容的对等依赖项。见上文。

所以在那时我更改了我的package.json,以便flex-layout处于版本^6.0.0-beta.15,然后运行:

npm update @angular/flex-layout

然后我再次尝试运行

ng update @angular/material

这是输出:

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 ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@2.0.1 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 codelyzer@2.0.1 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 worker-loader@0.8.1 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: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: 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/flex-layout@6.0.0-beta.15 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/material-moment-adapter@6.0.0 requires a peer of @angular/material@6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@2.0.1 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 codelyzer@2.0.1 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 worker-loader@0.8.1 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: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/material@5.2.5
+ @angular/cdk@5.2.5
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

关于我做错了什么或如何解决这个错误的任何想法?谢谢!

3 个答案:

答案 0 :(得分:1)

您可能遇到的问题多于此问题,但我怀疑您发布的代码底部的rxjs错误是因为6.0.0rxjs简化了导入删除深度导入的路径。这是一个值得欢迎的改变,但不幸的是,它也是一个突破性的改变。

所有运营商现在都在

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

过去,您必须从各自的目录中单独导入它们。

主题,观察,订阅等常见类都在

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

他们也发布了这有助于升级 - https://www.npmjs.com/package/rxjs-compat

如果您的任何依赖项依赖于rxjs的旧版本,您可能需要等待自己升级或修复它们

答案 1 :(得分:0)

就我而言,在做之前:ng update @angular/material

我先做过:npm uninstall @angular/flex-layout

然后,我可以成功安装角度材料。

答案 2 :(得分:0)

如果已安装tslintcodelyzer,请确保在运行ng update @angular/material之前将它们升级到最新版本。