在Ionic中,我在执行以下命令时遇到问题:
离子cordova build ios --prod
之后,在" ngc开始"将显示以下消息:
TypeError: Cannot read property 'assertNoMembers' of null
at AotSummaryResolver.resolveSummary (/dir/node_modules/@angular/compiler/bundles/compiler.umd.js:31986:21)
at CompileMetadataResolver._loadSummary (/dir/node_modules/@angular/compiler/bundles/compiler.umd.js:14710:66)
at CompileMetadataResolver._getEntryComponentMetadata (/dir/node_modules/@angular/compiler/bundles/compiler.umd.js:15742:66)
at /dir/node_modules/@angular/compiler/bundles/compiler.umd.js:14904:76
at Array.map (native)
at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (/dir/node_modules/@angular/compiler/bundles/compiler.umd.js:14904:22)
at /dir/node_modules/@angular/compiler/bundles/compiler.umd.js:29359:88
at Array.forEach (native)
at AotCompiler.findGeneratedFileNames (/dir/node_modules/@angular/compiler/bundles/compiler.umd.js:29358:25)
at Object.findGeneratedFileNames (/dir/node_modules/@angular/compiler-cli/src/transformers/program.js:392:82)
命令没有" - prod"工作良好。另外"离子服务"工作正常
答案 0 :(得分:3)
今天早上我遇到了同样的错误,对我来说问题是我的模块中有这样的错误:
@NgModule({
imports: [...],
declarations: [...],
entryComponents: components.filter(x => x.entryComponent)],
})
entryComponents应该是一个类型数组,以便编译器可以在编译时解析它。改变它来解决问题:
@NgModule({
imports: [...],
declarations: [...],
entryComponents: [MyComponent],
})
注意:如果您在使用ng服务时遇到此问题,则更改文件时会出现错误,并且角度会重新编译您的项目。
答案 1 :(得分:0)
我有Simon's problem的变体。修正案的扩展名相同。
// sidenavs is an object with keys and values, and values() is a lodash method that extracts only the values, which are components in this case
const mySidenavs = values(sidenavs)
@NgModule({
imports: [...],
declarations: [...],
entryComponents: [
// Spread operator breaks
...mySidenavs
]
})
只需导入每个单独修复的AOT版本。
@NgModule({
imports: [...],
declarations: [...],
entryComponents: [
Sidenav1,
...
SidenavN
]
})