I want to create some route with lazy load. But I can't get rid of error
Cannot find module app/search/search.module
Folder "search" is in the "app" folder, the path is correct. It works without webpack and this trouble starts after webpack configuring.
It works without lazy load.
Where is the problem?
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { RouterModule, Routes } from '@angular/router';
const appRoutes: Routes = [
{ path: 'search', loadChildren: 'app/search/search.module#SearchModule' },
{ path: '**', redirectTo: '/search' }
];
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot(appRoutes)
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
search.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SearchComponent } from "./search.component";
import { LocationsComponent } from "./locations/locations.component";
import { CommonModule } from "@angular/common";
import { GoogleMapsService } from "../shared/services/google-maps.service";
const routes: Routes = [
{ path: '', component: SearchComponent },
{ path: '**', redirectTo: '' }
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(routes)
],
exports: [
RouterModule
],
declarations: [ SearchComponent, LocationsComponent ],
providers: [ GoogleMapsService ]
})
export class SearchModule { }