Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to list lazy routes: Unknown module AppModule after Angular update

Tags:

angular

I'm not specifing lazy routing on app.module anywhere, but it throws me this error and fails to compile:

ERROR in Failed to list lazy routes: Unknown module '/Users/heikopiirme/Documents/realNewClient/client/src/app/app.module#AppModule'.

The only place I'm using lay loading is here:

{
    path: 'logistics',
    loadChildren: () => import('./views/logistics/logistics.module').then(m => m.LogisticsModule),
    canActivate: [ AuthGuard, NgxPermissionsGuard ],
    data: {
      permissions: {
        only: [Role.logistics_manager],
        redirectTo: '/home'
      }
    }
  }

This gave me an error but after switching to the new syntax it's fixed. How am I supposed to fix this for AppModule?

like image 522
eixcs Avatar asked Sep 24 '19 09:09

eixcs


2 Answers

I got this error after upgrading my learning project to 8 Like op, I was surprised to get this as I am not using lazy loading.

My issue was that one of the IMPORT statements was wrong. I finally happened to notice that.

import { HeroesComponent } from './Heroes/heroes1/heroes.component';
   and the error shows up

enableProdMode();

const routes: Routes = [
   { path: 'heroes', component: HeroesComponent },

If i correct the path to be (take out the 1 in the folder,heroes1--> heroes)

./Heroes/heroes/heroes.component

The error disappears and the app compiles.

This is a crazy red herring. Migrating to 8 from 7 has been rough for a variety of reasons. Hope this helps someone else.

like image 72
greg Avatar answered Nov 20 '22 08:11

greg


You dont need the import(...), its much simpler:

...
path: 'logistics', loadChildren: './views/logistics/logistics.module#LogisticsModule'
...
like image 1
Norbert Bartko Avatar answered Nov 20 '22 06:11

Norbert Bartko