在angular 7中执行ng构建时出错--prod=true--optimization=true

在angular 7中执行ng构建时出错--prod=true--optimization=true,angular,angular-cli,angular7,Angular,Angular Cli,Angular7,当我尝试执行以下ng build命令--prod=true--optimization=true或执行ng build命令--prod=true时,出现以下错误: ERROR in : Error: Illegal State: literal arrays should have been converted into functions at _AstToIrVisitor.visitLiteralArray (/mnt/98d9abc7-78bd-4fe3-b361-0111a53

当我尝试执行以下ng build命令--prod=true--optimization=true或执行ng build命令--prod=true时,出现以下错误:

ERROR in : Error: Illegal State: literal arrays should have been converted into functions
    at _AstToIrVisitor.visitLiteralArray (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7338:19)
    at LiteralArray.visit (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:6433:28)
    at _AstToIrVisitor._visit (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7445:52)
    at _AstToIrVisitor.visitConditional (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7287:120)
    at Conditional.visit (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:6320:28)
    at convertPropertyBinding (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7143:52)
    at TemplateDefinitionBuilder.convertPropertyBinding (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14371:44)
    at /mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14174:35
    at /mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14331:71
    at /mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13787:86
    at Array.map (<anonymous>)
    at TemplateDefinitionBuilder.buildTemplateFunction (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13787:56)
    at /mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14245:60
    at /mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13762:81
    at Array.forEach (<anonymous>)
    at TemplateDefinitionBuilder.buildTemplateFunction (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13762:37)
    at compileComponentFromMetadata (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:15097:58)
    at compileComponentFromRender2 (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:15183:19)
    at /mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23990:21
    at Array.forEach (<anonymous>)
    at AotCompiler._compilePartialModule (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23966:24)
    at /mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23948:58
    at Array.forEach (<anonymous>)
    at AotCompiler.emitAllPartialModules (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23948:19)
    at AngularCompilerProgram._emitRender3 (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler-cli/src/transformers/program.js:211:43)
    at AngularCompilerProgram.emit (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@angular/compiler-cli/src/transformers/program.js:200:59)
    at AngularCompilerPlugin._emit (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:873:49)
    at AngularCompilerPlugin._update (/mnt/98d9abc7-78bd-4fe3-b361-0111a5393954/git/venta-generica-fe/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:676:50)

错误:错误:非法状态:文字数组应已转换为函数
在_asttoivisitor.visitliteralararray(/mnt/98d9abc7-78bd-4fe3-b361-0111a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7338:19)
访问LiteralArray.visit(/mnt/98d9abc7-78bd-4fe3-b361-0111a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:6433:28)
访问(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7445:52)
访问条件(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7287:120)
在Conditional.visit(/mnt/98d9abc7-78bd-4fe3-b361-0111a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:6320:28)
在convertPropertyBinding(/mnt/98d9abc7-78bd-4fe3-b361-0111A53954/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:7143:52)
在TemplateDefinitionBuilder.convertPropertyBinding(/mnt/98d9abc7-78bd-4fe3-b361-011A53954/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14371:44)
at/mnt/98d9abc7-78bd-4fe3-b361-0111A539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14174:35
at/mnt/98d9abc7-78bd-4fe3-b361-0111A539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14331:71
at/mnt/98d9abc7-78bd-4fe3-b361-0111A539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13787:86
在Array.map()处
在TemplateDefinitionBuilder.buildTemplateFunction(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13787:56)
at/mnt/98d9abc7-78bd-4fe3-b361-0111A539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:14245:60
at/mnt/98d9abc7-78bd-4fe3-b361-0111A539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13762:81
在Array.forEach()处
在TemplateDefinitionBuilder.buildTemplateFunction(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:13762:37)
在compileComponentFromMetadata(/mnt/98d9abc7-78bd-4fe3-b361-0111a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:15097:58)
在Render2的CompileComponent(/mnt/98d9abc7-78bd-4fe3-b361-0111A53954/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:15183:19)
at/mnt/98d9abc7-78bd-4fe3-b361-0111A539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23990:21
在Array.forEach()处
在AOT编译器上编译部分模块(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23966:24)
at/mnt/98d9abc7-78bd-4fe3-b361-0111A539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23948:58
在Array.forEach()处
在AotCompiler.emitAllPartialModules(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@angular/compiler/bundles/compiler.umd.js:23948:19)
在AngularCompilerProgram._emitRender3(/mnt/98d9abc7-78bd-4fe3-b361-0111A53954/git/venta generica fe/node_modules/@angular/compiler cli/src/transformers/program.js:211:43)
在AngularCompilerProgram.emit(/mnt/98d9abc7-78bd-4fe3-b361-0111A53954/git/venta generica fe/node_modules/@angular/compiler cli/src/transformers/program.js:200:59)
在AngularCompilerPlugin.发出(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:873:49)
在AngularCompilerPlugin.更新(/mnt/98d9abc7-78bd-4fe3-b361-011a539354/git/venta generica fe/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:676:50)
如果我运行ng build,我就没有问题了
当我添加--prod=true或-prod和--optimization=true时,问题就开始了。您可以通过将tsconfig.json设置为禁用常春藤:“angularCompilerOptions”:{“enableIvy”:false}绕过此错误,将tsconfig.json设置为禁用常春藤:“angularCompilerOptions”:{“enableIvy”:false}