I am getting a weird error. I am developing angular 4 based project. Following in my code structure
- app
- app.component.html
- app.component.ts
- app.module.ts
- app.routing.module.ts
- dashboard
- dashboard.component.html
- dashboard.component.ts
- dashboard.module.ts
- dashboard.routing.module.ts
- first
- first.component.html
- first.component.ts
- first.module.ts
- first.routing.module.ts
When I try to load first from dashboard, I get following error.
ERROR Error: Uncaught (in promise): Error: Cannot find module 'app/dashboard/first/first.module'.
Error: Cannot find module 'app/dashboard/first/first.module'.
at webpackAsyncContext (src async:14)
at SystemJsNgModuleLoader.webpackJsonp.../../../core/@angular/core.es5.js.SystemJsNgModuleLoader.loadAndCompile (core.es5.js:5644)
at SystemJsNgModuleLoader.webpackJsonp.../../../core/@angular/core.es5.js.SystemJsNgModuleLoader.load (core.es5.js:5632)
at RouterConfigLoader.webpackJsonp.../../../router/@angular/router.es5.js.RouterConfigLoader.loadModuleFactory (router.es5.js:3417)
at RouterConfigLoader.webpackJsonp.../../../router/@angular/router.es5.js.RouterConfigLoader.load (router.es5.js:3401)
at MergeMapSubscriber.project (router.es5.js:1569)
Following is my app.routing.module code
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{ path: '', loadChildren: 'app/login/login.module' },
{ path: 'dashboard', loadChildren: 'app/dashboard/dashboard.module' },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
At compile time there is no error. However when I add a space in dashboard.routing.module.ts and save the file, the error goes away and the routing works perfectly. It runs smoothly till I restart node server.