Hi,when i use ionic 3 lazy loading page,i just do it follow the demo,but a error occur:
Runtime Error
Uncaught (in promise): Error: Cannot find module '../pages/home/home.module'. Error: Cannot find module '../pages/home/home.module'. at webpackEmptyContext (http://localhost:8100/build/main.js:74030:8) at loadAndCompile (http://localhost:8100/build/main.js:73119:36) at NgModuleLoader.load (http://localhost:8100/build/main.js:73084:83) at ModuleLoader.load (http://localhost:8100/build/main.js:54758:44) at DeepLinker.getNavLinkComponent (http://localhost:8100/build/main.js:26281:39) at DeepLinker.getComponentFromName (http://localhost:8100/build/main.js:26264:25) at getComponent (http://localhost:8100/build/main.js:29339:23) at convertToView (http://localhost:8100/build/main.js:29357:16) at convertToViews (http://localhost:8100/build/main.js:29376:32) at NavControllerBase._loadLazyLoading (http://localhost:8100/build/main.js:43086:108)
Stack
Error: Uncaught (in promise): Error: Cannot find module '../pages/home/home.module'.
Error: Cannot find module '../pages/home/home.module'.
at webpackEmptyContext (http://localhost:8100/build/main.js:74030:8)
at loadAndCompile (http://localhost:8100/build/main.js:73119:36)
at NgModuleLoader.load (http://localhost:8100/build/main.js:73084:83)
at ModuleLoader.load (http://localhost:8100/build/main.js:54758:44)
at DeepLinker.getNavLinkComponent (http://localhost:8100/build/main.js:26281:39)
at DeepLinker.getComponentFromName (http://localhost:8100/build/main.js:26264:25)
at getComponent (http://localhost:8100/build/main.js:29339:23)
at convertToView (http://localhost:8100/build/main.js:29357:16)
at convertToViews (http://localhost:8100/build/main.js:29376:32)
at NavControllerBase._loadLazyLoading (http://localhost:8100/build/main.js:43086:108)
at c (http://localhost:8100/build/polyfills.js:3:12642)
at Object.reject (http://localhost:8100/build/polyfills.js:3:11998)
at NavControllerBase._fireError (http://localhost:8100/build/main.js:42996:16)
at NavControllerBase._failed (http://localhost:8100/build/main.js:42984:14)
at http://localhost:8100/build/main.js:43039:59
at t.invoke (http://localhost:8100/build/polyfills.js:3:8488)
at Object.onInvoke (http://localhost:8100/build/main.js:4403:37)
at t.invoke (http://localhost:8100/build/polyfills.js:3:8428)
at r.run (http://localhost:8100/build/polyfills.js:3:3686)
at http://localhost:8100/build/polyfills.js:3:13183
Ionic Framework: 3.2.1
Ionic App Scripts: 1.3.7
Angular Core: 4.1.0
Angular Compiler CLI: 4.1.0
Node: 6.10.3
OS Platform: Windows 10
Navigator Platform: Win32
Need a little more info than that to be sure of the problem, but make sure you’ve got a home.module.ts file in the same folder as your home.ts component file.
import { Component } from '@angular/core';
import { NavController,IonicPage } from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
}
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
// import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
// HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
// HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
// import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = 'HomePage';
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
}
I’m pretty certain that it is not required to add lazily loaded page modules to the app module. I think OP’s issue is caused by a bad relative path somewhere; an import of “…/pages/home/home.module” from somewhere from which that is not a valid path.