Я создал новый проект Angular 8 с @ angular / cli -> ng new, добавил новый ленивый модуль, с ng serve работает нормально, , но с ng build -prod возникает следующая ошибка:
Вот мой app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Вотмой app-routing.module.ts
const appRoutes: Routes = [
{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full',
},
{
path: 'dashboard',
loadChildren: () => import(`./dashboard/dashboard.module`).then(m => m.DashboardModule),
}
];
@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
Вот мой dashboard.module.ts
@NgModule({
imports: [
DashboardRoutingModule
],
declarations: [
DashboardComponent,
]
})
export class DashboardModule { }
Вот мой dashboard-routing.module.ts
const ROUTES: Routes = [
{
path: '',
component: DashboardComponent
}
];
@NgModule({
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule]
})
export class DashboardRoutingModule { }
Это мой tsconfig.json (по умолчанию)
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}