I did Angular upgrade from Angular.Js 1.6.6 to Angular 6 using Webpack 4:
import 'core-js/es7/reflect'; import 'zone.js'; import 'reflect-metadata'; import 'rxjs'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { Routes, RouterModule } from '@angular/router'; import { BrowserModule } from '@angular/platform-browser'; import { UpgradeModule, downgradeComponent, downgradeInjectable, setAngularJSGlobal } from '@angular/upgrade/static'; import { module } from './app.module.ajs'; import './config/routes'; import AppComponent from './components/app/app'; import Application from './directives/application/application'; import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; console.log('NgModule'); const appRoutes: Routes = [ ]; @NgModule({ declarations: [AppComponent, Application], entryComponents: [AppComponent], imports: [ BrowserModule, FormsModule, RouterModule.forRoot(appRoutes), UpgradeModule ] }) class AppModule { constructor(public upgrade: UpgradeModule) { console.log('AppModule constructor'); } ngDoBootstrap() { console.log('AppModule ngDoBootstrap'); } } console.log('setAngularJSGlobal ...'); setAngularJSGlobal(window['angular']); console.log('setAngularJSGlobal!!!'); import main = require('./main'); console.log('Before bootstrapModule module.name: ', module.name); platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => { console.log('Hybrid mode: Angular + Angular.Js'); module.directive('appRoot', downgradeComponent({ component: AppComponent })); const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule; console.log('bootstrapModule: ', module.name); main['launchAngular'](); upgrade.bootstrap(document.body, [module.name], { strictDi: true }); });
created custom alias, added correct paths to tsconfig, Webpack build pass & produce output, but when application starts in browser, error popups in console: ngRoute is missing or incorrect ng module components What is not done correctly & how to fix this error?