0

我正在使用 angular/cli 6.1.3 并在尝试使用 enableIvy: true in 进行编译时出现以下错误tsconfig.app.json

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
4

1 回答 1

0

这对我有用:

BrowserModule从文件中删除app.module.ts,从 ngModule 声明的导入部分和文件顶部的实际 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,等不及了。

于 2018-10-24T16:52:37.460 回答