I\'m upgrading from Angular 4.0.0 to Angular 5.2.6
i\'m facing some problem to get lazy module loading working.
with
i have resolved this issue by upgrading mt angular-cli locally in the devDependenices (package.json) from 1.2.0 to 1.6.7
I had exactly the same issue but simply restarting the nodes server (ng s) did the trick for me.
As a rule of thumb: if angular starts behaving strange, first try to restart your nodes server
Solution 1
Imports order does matter so import lazy loaded module
in top and router module
in the last place. Because we are doing lazy loading, that lazy-loaded module has to exist before we do routing.
imports: [
BrowserModule,
HeroModule, // Lazy-loaded module
AppRoutingModule
],
Solution 2
Usually Angular CLI
will import the module
to app-module
when it was generated. so make sure lazy-loaded
module was not imported in app-module
As mentioned in https://github.com/angular/angular-cli/issues/9488#issuecomment-368871510 it seems to work with ng serve --aot