Lazy loading modules not working

When using lazy loaded routes, i’m getting this error
Error: Uncaught (in promise): Error: Loading chunk 0 failed.

I have used this and it’s working fine except when i’m using the lazy loading like
{path: 'records', loadChildren: './components/records/records.module#RecordsModule', canActivate: [AuthGuardService]}

I thought it is because of {useHash: true}, but after removing this the first part was not working.

1 possible answer(s) on “Lazy loading modules not working

  1. Try to use an absolute path instead of relative path.
    In your case is something like: loadChildren: 'app/components/records/records.module#RecordsModule'.