gpt4 book ai didi

angular - 升级到 Angular Material 6.0.0 时出错

转载 作者:太空狗 更新时间:2023-10-29 19:26:07 26 4
gpt4 key购买 nike

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

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

上面的运行没有错误(虽然有一些警告),但是 ng update 实际上并没有改变配置文件,除非我第二次运行它。第二次之后一切正常。

ng update @angular/core

这运行正常,但提示(警告)@angular/flex-layout@5.0.0-beta.14。

ng update @angular/material

这会产生:

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.

所以那时我更改了 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

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

最佳答案

您可能遇到的问题不止于此,但我怀疑您在发布的代码底部遇到的有关 rxjs 的错误是因为 6.0.0 版本rxjs 通过删除深层导入简化了导入路径。这是一个可喜的变化,但不幸的是,它也是一个破坏性的变化。

现在所有的运营商都在

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

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

Subjects, observables, subscriptions 等常用类都在

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

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

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

关于angular - 升级到 Angular Material 6.0.0 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50179686/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com