我用Angular-cli创建了一个应用程序,当我运行 ng serveng build 时一切正常,我没有任何错误;但是当我运行 ng build -aot 时,我有以下错误:

子编译中的错误失败:模块构建失败:错误:使用“extract-text-webpack-plugin”加载器而没有相应的插件参考https://github.com/webpack/extract-text-webpack-plugin Object.module.exports.pitch上的用法示例:错误:使用“extract-text-webpack-plugin”加载器而没有相应的插件参考https://github.com/webpack/extract-text-webpack-plugin使用示例./src/main.ts中的错误找不到模块:错误:无法解析'C:... \ src'中的'./$$_gendir/app/app.module.ngfactory'@ ./src /main.ts 4:0-74 @ multi ./src/main.ts

我试着看Github,但我不明白可能是什么问题 . 我也尝试更新所有模块和angular-cli,但它使情况变得更糟(应用程序不再工作,构建需要花费一个多小时的新错误)

这可能来自哪些想法以及如何解决这些错误?

Versions :

  • @ angular / cli:1.0.0

  • node:6.10.1

  • os:win32 x64

  • @ angular / common:4.1.3

  • @ angular / compiler:4.1.3

  • @ angular / core:4.1.3

  • @ angular / forms:4.1.3

  • @ angular / http:4.1.3

  • @ angular / platform-browser:4.1.3

  • @ angular / platform-browser / dynamic:4.1.3

  • @ angular / router:4.1.3

  • @ angular / compiler-cli:4.1.3

EDIT - 所以我跟着this tutorial:安装@ angular / platform-server,创建一个tsconfig-aot.json,运行 "node_modules/.bin/ngc" -p tsconfig-aot.json 并编辑我的main.ts来自

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);

import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory';

platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);

现在我只有一个错误:

试图找到boostrap代码,但不能 . 指定静态可分析引导代码或将entryModule传递给插件选项 . 在Object.resolveEntryModuleFromMain C:... \ node_modules \ @ngtools \ webpack \ src \ entry_resolver.js:128:11 at AotPlugin._setupOptions C:... \ node_modules \ @ngtools \ webpack \ src \ plugin.js:142 :在新的AotPlugin C上50:... \ node_modules \ @ngtools \ webpack \ src \ plugin.js:26:14在_createAotPlugin C:... \ node_modules \ @angular \ cli \ models \ webpack-configs \ typescript . js:55:12 atObject.exports.getNonAotConfig C:... \ node_modules \ @angular \ cli \ models \ webpack-configs \ typescript.js:70:19 at NgCliWebpackConfig.buildConfig C:... \ node_modules \ @angular \ cli \ models \ webpack-configs.js:27:37在Class.run C:... \ node_modules \ @angular \ cli \ tasks \ serve.js:37:98 at check_port_1.checkPort.then.port C: ... \ node_modules \ @angular \ cli \ commands \ serve.js:103:26 at process._tickCallback internal / process / next_tick.js:109:7