尝试迁移到Angular 9时出错:为导出的符号生成的元数据中遇到错误

问题描述

我正在尝试将Angular 8应用程序转换为Angular9。在运行迁移命令时,我看到了:

Undecorated classes with DI migration.
      As of Angular 9,it is no longer supported to use Angular DI on a class that does not have an Angular decorator.
      Read more about this here: https://v9.angular.io/guide/migration-undecorated-classes
    
        This migration uses the Angular compiler internally and therefore projects that no longer build successfully after the update cannot run the migration. Please ensure there are no AOT compilation errors and rerun the migration. The following project failed: libs/core/tsconfig.lib.json
    
        Error: ~/core-routing.module.ts:138:1: Error encountered in metadata generated for exported symbol 'CoreRoutingModule':
         ~/core/src/lib/core-routing.module.ts:25:23: Metadata collected contains an error that will be reported at runtime: Lambda not supported.
          {"__symbolic":"error","message":"Lambda not supported","line":24,"character":22}
    
        Could not migrate all undecorated classes that use dependency
        injection. Some project targets could not be analyzed due to
        TypeScript program failures.
    
        Migration can be rerun with: "ng update @angular/core --migrate-only migration-v9-undecorated-classes-with-di"
    
      Migration completed.

Nx workspace : 8.12.0

Angular : 8

解决方法

strictMetadataEmit是库的标志,因此完全不应有任何延迟加载的模块。它不打算用于应用程序。

"strictMetadataEmit": false,

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...