PageModule declared twice


#1
 ./androidProd.sh
Switched to branch 'androidProd'
Already up-to-date.
[INFO] Running app-scripts build: --prod --platform android --target cordova

[19:58:03]  build prod started ...
[19:58:03]  clean started ...
[19:58:03]  clean finished in 1 ms
[19:58:03]  copy started ...
[19:58:03]  ngc started ...
Error: Type DisclaimerPage in /Users/me/Documents/MyApp/src/pages/disclaimer/disclaimer.ts is part of the declarations of 2 modules: AppModule in /Users/me/Documents/MyApp/src/app/app.module.ts and DisclaimerPageModule in /Users/me/Documents/MyApp/src/pages/disclaimer/disclaimer.module.ts! Please consider moving DisclaimerPage in /Users/me/Documents/MyApp/src/pages/disclaimer/disclaimer.ts to a higher module that imports AppModule in /Users/me/Documents/MyApp/src/app/app.module.ts and DisclaimerPageModule in /Users/me/Documents/MyApp/src/pages/disclaimer/disclaimer.module.ts. You can also create a new NgModule that exports and includes DisclaimerPage in /Users/me/Documents/MyApp/src/pages/disclaimer/disclaimer.ts then import that NgModule in AppModule in /Users/me/Documents/MyApp/src/app/app.module.ts and DisclaimerPageModule in /Users/me/Documents/MyApp/src/pages/disclaimer/disclaimer.module.ts.

Is it because I do this in app.modules.ts

import { MyApp } from './app.component';

import { DisclaimerPage } from '../pages/disclaimer/disclaimer';


@NgModule({
  declarations: [
    MyApp,
    DisclaimerPage
  ]
  ,
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    DisclaimerPage],
  providers: [....

and ionic generate has as well created a disclaimer.module.ts?

import { NgModule } from '@angular/core';

import { IonicPageModule } from 'ionic-angular';
import { DisclaimerPage } from './disclaimer';

@NgModule({
  declarations: [
    DisclaimerPage,
  ],
  imports: [
    IonicPageModule.forChild(DisclaimerPage),
  ],
})
export class DisclaimerPageModule {}

#2

Same for
ionic cordova build ios --prod


#3

Hello,
the error mesage says that 1 declaration is to much.

disclaimer.module.ts is needed, if you want use lazy loading.

If you use lazy loading, then remove the import and declaration from app.module.ts

Best regards. anna-liebt


#4

Thanks Anna,
Yes, I just figured it out, too.

I had to delete the *modules.ts files and delete the @IonoicPage decorator in each page definition.
Thanks