Answer the question
In order to leave comments, you need to log in
After upgrading Angular from 4 to 6, how do I get lazy routes to work?
There are lazy routes in a project written under Angular 4.
After upgrading to 6, a lot of errors are generated:
ERROR in ./src/$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve '/path/to/project/src/app/lazy/about/about.module.ngfactory.js' in '/path/to/project/src/$$_lazy_route_resource'
export const AppRoutes: Routes = [
(...)
{
path: 'about-us',
loadChildren: './lazy/about/about.module#AboutModule'
},
(...)
]
import {RouterModule} from '@angular/router';
import {ModuleWithProviders} from '@angular/core';
import {AppRoutes} from './app.routes';
/**
* @type {ModuleWithProviders}
*/
export const AppRoutingModule: ModuleWithProviders = RouterModule.forRoot(AppRoutes);
ng build --prod --aot --output-hashing=all
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question