Page is part of the declarations of 2 modules: Error in ionic build prod

后端 未结 3 1367
生来不讨喜
生来不讨喜 2020-11-27 23:04

When I run npm run ionic:build I am able to build successfully. But When I run npm run ionic:build --prod I am getting following error mess

3条回答
  •  心在旅途
    2020-11-27 23:31

    If you are using a component as an entryComponent within a module you do not need to declare it within the Module. Try removing PatientDetailPage from the declarations on your app.module.ts.

    So the best way to do this in my opinion is to export your PatientDetailPage out from your PatientDetailModule and import the PatientDetailModule into your App Module.

    App Module

    @NgModule({
      imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp),
        AngularFireDatabaseModule,
        AngularFireModule.initializeApp(firebaseConfig),
        AngularFireOfflineModule,
        PatientDetailModule,
        IonicStorageModule.forRoot()
       // PatientDetailPage
    
      ],
      declarations: [
        MyApp,
        HomePage
      ],
      entryComponents: [
        MyApp,
        HomePage,
        PatientDetailPage
      ],
      providers: [
        StatusBar,
        SplashScreen,
        //AngularFireModule,
        //Storage,
        {provide: ErrorHandler, useClass: IonicErrorHandler}
      ],
       bootstrap: [IonicApp],
    })
    

    Patient Module

    import { NgModule } from '@angular/core';
    import { IonicPageModule } from 'ionic-angular';
    import { PatientDetailPage } from './patient-detail';
    
    @NgModule({
      declarations: [
        PatientDetailPage,
      ],
      imports: [
        IonicPageModule.forChild(PatientDetailPage),
      ],
      exports: [
        PatientDetailPage
      ]
    
    })
    export class PatientDetailPageModule {
    
    }
    

提交回复
热议问题