我正在使用angular / cli 6.1.3,并在尝试使用enableIvy进行编译时出现以下错误:tsconfig.app.json
中的true:
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in 'xxxxPath'
构建命令:
ng build --prod --source-map=false --base-href='/' --extract-css=true --delete-output-path=true --aot --build-optimizer=true
angular / cli的版本详细信息
Angular CLI: 6.1.3
Node: 10.7.0
OS: linux x64
Angular: 6.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.7.3
@angular-devkit/build-angular 0.7.3
@angular-devkit/build-optimizer 0.7.3
@angular-devkit/build-webpack 0.7.3
@angular-devkit/core 0.7.3
@angular-devkit/schematics 0.7.3
@angular/cli 6.1.3
@ngtools/webpack 6.1.3
@schematics/angular 0.7.3
@schematics/update 0.7.3
rxjs 6.2.2
typescript 2.7.2
webpack 4.9.2
答案 0 :(得分:0)
这对我有用:
从BrowserModule
文件中删除app.module.ts
,从ngModule声明的imports部分和实际ES5导入都在文件顶部
并在main.ts
中修改引导程序:
import { enableProdMode, ɵrenderComponent } from '@angular/core';
import { environment } from './environments/environment';
import { AppComponent } from './app/routes/app/app.component';
if (environment.production) {
enableProdMode();
}
ɵrenderComponent(<any>AppComponent);
主捆绑包从1.4mB变为636kB,迫不及待。