0

This app is trying to load the BookModule lazily with this configuration:

const routes: Routes = [
  { path: "", redirectTo: "/books", pathMatch: "full" },
  {
    path: "books",
    loadChildren: "./modules/book/book.module#BookModule",
    canActivate: [AuthGuard]
  },
  { path: "login", component: LoginComponent }
];

And it's producing the error:

Error: Cannot find 'BookModule' in './modules/book/book.module'

Thoughts?

1 Answer 1

1

Seems like your Angular version is 11.

The lazy loading syntax changed. It is something like this now

const routes: Routes = [
  {
    path: 'items',
    loadChildren: () => import('./items/items.module').then(m => m.ItemsModule)
  }
];

So your code should be like this

const routes: Routes = [
  { path: "", redirectTo: "/books", pathMatch: "full" },
  {
    path: "books",
    loadChildren: () => import('./modules/book/book.module').then(m => m.BookModule),
    canActivate: [AuthGuard]
  },
  { path: "login", component: LoginComponent }
];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.