I created an application with Angular-cli, and when I run ng serve
or ng build
everything works fine, I don't have any error; but when I run ng build -aot
I have the following errors :
ERROR in Child compilation failed: Module build failed: Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin
refer to https://github.com/webpack/extract-text-webpack-plugin for the usage example at Object.module.exports.pitch : Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin
refer to https://github.com/webpack/extract-text-webpack-plugin for the usage example
ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:...\src' @ ./src/main.ts 4:0-74 @ multi ./src/main.ts
I tried looking on Github but I didn't understand what could be the problem. I also tried to update all modules and angular-cli but it made it worse (application not working anymore and building was taking more than an hour with new errors)
Any ideas where this might come from and how to resolve these errors ?
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 - So I followed this tutorial : install @angular/platform-server, create a tsconfig-aot.json, run "node_modules/.bin/ngc" -p tsconfig-aot.json
and edit my main.ts from
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
to
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory';
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
and now I have only one error :
Tried to find boostrap code, but could not.Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
at 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:50
at new AotPlugin C:...\node_modules\@ngtools\webpack\src\plugin.js:26:14
at _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
at 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