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?
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 }
];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.