0

Error: enter image description here

I am facing a problem when I run the code via ionic serve I get an error of Runtime error: Cannot find module "."

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 { SigninPage } from '../pages/auth/signin/signin';
import { SignupPage } from '../pages/auth/signup/signup';
import { LandingPage } from '../pages/landing/landing';
import { AuthService } from '../services/auth.service';

@NgModule({
  declarations: [
    MyApp,
    SigninPage,
    SignupPage,
    LandingPage
  ],
imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  providers: [
    StatusBar,
    SplashScreen,
    AuthService,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]

I haven't mention the entrycomponents and all the components contains the default code. AuthService is also empty

If I remove the AuthService form Providers in app.module file Code runs succesfully. But if I have to access the authService I must provide it in the Providers

5
  • This happens if something is not imported correctly. For example NavController has to be imported from ionic-angular, not ionic-angular/umd - that does vs code automatically. Commented Aug 17, 2018 at 19:40
  • the problem is only in the app.module.ts file or in other file @ Gregor Ojstersek Commented Aug 17, 2018 at 19:42
  • Can you share the code in app.module file? And maybe one other random component? Commented Aug 17, 2018 at 19:50
  • @Gregor Ojstersek Post edited Commented Aug 17, 2018 at 20:04
  • Check the imports in all your ts files including AuthService Commented Aug 18, 2018 at 9:46

1 Answer 1

1

IonicPageModule is missing from your project.

In your app.module.ts include

import { IonicPageModule } from 'ionic-angular';

And your import should looks like this:

imports: [
    BrowserModule,
    IonicPageModule.forChild(HomePage)
    IonicModule.forRoot(MyApp)
  ],

after that run npm run-script build

NOTE: IonicPageModule is an NgModule that bootstraps a child IonicPage in order to set up routing.

Sign up to request clarification or add additional context in comments.

1 Comment

Happy coding :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.