我不能通过ng服务

  • 本文关键字:ng 服务 不能 angular
  • 更新时间 :
  • 英文 :


每当我输入ng serve它都会打印:

您的全局 Angular CLI 版本 (10.0.1( 高于您的本地版本 版本 (6.2.9(。使用本地 Angular CLI 版本。

要禁用此警告,请使用ng config -g cli.warnings.versionMismatch false

Schema validation failed with the following errors:
Data path ".builders['app-shell']" should have required property 'class'.
Error: Schema validation failed with the following errors:
Data path ".builders['app-shell']" should have required property 'class'.
at MergeMapSubscriber.project (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modules@angular-devkitcoresrcworkspaceworkspace.js:210:42)
at MergeMapSubscriber._tryNext (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternaloperatorsmergeMap.js:65:27)
at MergeMapSubscriber._next (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternaloperatorsmergeMap.js:55:18)
at MergeMapSubscriber.Subscriber.next (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternalSubscriber.js:64:18)
at MergeMapSubscriber.notifyNext (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternaloperatorsmergeMap.js:84:26)
at InnerSubscriber._next (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternalInnerSubscriber.js:25:21)
at InnerSubscriber.Subscriber.next (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternalSubscriber.js:64:18)
at MapSubscriber._next (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternaloperatorsmap.js:52:26)
at MapSubscriber.Subscriber.next (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternalSubscriber.js:64:18)
at SwitchMapSubscriber.notifyNext (d:문현주DesktopCoursera BootstrapAngularconFusionnode_modulesrxjsinternaloperatorsswitchMap.js:77:26)

有谁知道如何解决它们?

您基本上有三个选项可以修复版本不匹配:

  • 使用npm i -g @angular/cli@6.9.2安装与全局 Angular CLI 相同的 Angular 版本(仅当这是您唯一的 Angular 项目时才推荐(
  • 将项目更新为全局 CLI 的版本
  • 按照说明禁止显示警告。如果ng config -g cli.warnings.versionMismatch false对您不起作用,您可以通过将设置添加到项目angular.json末尾来手动关闭警告:
"defaultProject": "my-awesome-project",
+    "cli": {
+      "warnings": {
+        "versionMismatch": false
+      }
+    }
}

最新更新