title: Typescript error - The Angular AoT build failed - Node.js + Ionic mobile app
body: <p>I'm trying to create an Android app (Node.js + Ionic) that shows random text and pictures (the selection of texts and pictures are stored in arrays). I'm trying to install this app on my phone. The app works in Chrome. </p>
  
  <p>When I give the ionic serve command in the command prompt, it works perfectly in Chrome, Random1 gives a random text and a random picture every time I push the next button, Random2 only gives a random picture every time I push the next button. 
  When I give the "ionic cordova run android --prod --release" command in the command prompt, I get this error:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>[16:54:50]  build prod started ...
  [16:54:50]  clean started ...
  [16:54:50]  clean finished in 6 ms
  [16:54:50]  copy started ...
  [16:54:50]  deeplinks started ...
  [16:54:50]  deeplinks finished in 84 ms
  [16:54:50]  ngc started ...
  [16:55:02]  typescript error
              Type Random1Page in
              C:/.../pages/random1/random1.ts is part of the declarations of 2 modules: AppModule in
              C:/.../app/app.module.ts and
              Random1PageModule in
              C:/.../pages/random1/random1.module.ts!
              Please consider moving Random1Page in
              C:/.../pages/random1/random1.ts to a higher module that imports AppModule in
              C:/.../app/app.module.ts and Random1PageModule in
              C:/.../pages/random1/random1.module.ts. You
              can also create a new NgModule that exports and includes Random1Pag
  e in C:/.../pages/random1/random1.ts then import that NgModule in AppModule in
              C:/.../app/app.module.ts and
              Random1PageModule in
              C:/.../pages/random1/random1.module.ts.
  Typescript error - Error: The Angular AoT build failed. See the issues above
      at C:/...\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
      at step (C:/...\no
  de_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
      at Object.next (C:/...\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
      at fulfilled (C:/...\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
      at anonymous</code></pre>
  </div>
  </div>
  </p>
  
  <p>I gave this command from the folder of the ionic app. This folder contains these folders:</p>
  
  <p><a href="https://i.stack.imgur.com/BSCsV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BSCsV.png" alt="enter image description here"></a></p>
  
  <p>Is this the right folder to give this command?</p>
  
  <p>random1.ts:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Component } from '@angular/core';
  import { IonicPage, NavController, NavParams } from 'ionic-angular';
  import { Random2Page } from '../random2/random2';
  
  @IonicPage()
  @Component({
    selector: 'page-random1',
    templateUrl: 'random1.html',
  })
  export class Random1Page {
    random1_arr: string[]= ["text1", "text2", "text3"];
    random1_act: string;
    image_arr: string[]= ["../assets/imgs/Pic1.jpg", "../assets/imgs/Pic2.jpg"];
    image_act: string;
    person_arr: string[]= ["person1", "person2"];
    person_act: string;
    person_not_act: string;
    counter= 0;
  
    constructor(public navCtrl: NavController, public navParams: NavParams) {
      this.image_act= '';
      let random_index= Math.floor(Math.random() * 2);
      this.person_act= this.person_arr[random_index];
      this.person_not_act= this.person_arr[random_index? 0: 1];
      this.GenerateRandom1PicturePerson();
    }
  
    GenerateRandom1PicturePerson() {
      this.random1_act= this.random1_arr[Math.floor(Math.random() * this.random1_arr.length)];
      this.image_act= this.image_arr[Math.floor(Math.random() * this.image_arr.length)];
      this.person_act= [this.person_not_act, this.person_not_act= this.person_act][0];
      this.counter++;
  
      if(this.counter &gt;= 7) {
        this.navCtrl.push(Random2Page);
      }
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>app.module.ts:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { BrowserModule } from '@angular/platform-browser';
  import { ErrorHandler, NgModule } from '@angular/core';
  import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
  
  import { MyApp } from './app.component';
  import { HomePage } from '../pages/home/home';
  import { ListPage } from '../pages/list/list';
  import { Random1Page } from '../pages/random1/random1';
  import { Random2Page } from '../pages/random2/random2';
  import { LoggedinPage } from '../pages/loggedin/loggedin';
  
  import { StatusBar } from '@ionic-native/status-bar';
  import { SplashScreen } from '@ionic-native/splash-screen';
  
  @NgModule({
    declarations: [
      MyApp,
      HomePage,
      ListPage,
      Random1Page,
      Random2Page,
      LoggedinPage
    ],
    imports: [
      BrowserModule,
      IonicModule.forRoot(MyApp),
    ],
    bootstrap: [IonicApp],
    entryComponents: [
      MyApp,
      HomePage,
      ListPage,
      Random1Page,
      Random2Page,
      LoggedinPage
    ],
    providers: [
      StatusBar,
      SplashScreen,
      {provide: ErrorHandler, useClass: IonicErrorHandler}
    ]
  })
  export class AppModule {}</code></pre>
  </div>
  </div>
  </p>