I get build prod failed: Unexpected value... when run "sudo ionic build --prod"

Hello colleagues,

Im trying to build with the the option --prod and I get this error “build prod failed: Unexpected value ‘LoginPage’ declared by the module ‘AppModule’”, but if i run ionic build without the --prod options its work perfect.

My Code
app.module.ts

import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import {
  LoginPage, HomePage,
  AcademyPage, AcademyDetailPage,
  ProfilePage, ReservationPage,
  ReservationFilterPage,PaymentTabsPage,
  ActivityDetailPage
} from '../page';




@NgModule({
  declarations: [
    MyApp,
    LoginPage,
    HomePage,
    AcademyPage,
    AcademyDetailPage,
    ProfilePage,
    ReservationPage,
    ReservationFilterPage,
    PaymentTabsPage,
    ActivityDetailPage
  ],
  imports: [
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    LoginPage,
    HomePage,
    AcademyPage,
    AcademyDetailPage,
    ProfilePage,
    ReservationPage,
    ReservationFilterPage,
    PaymentTabsPage,
    ActivityDetailPage
  ],
  providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }]
})
export class AppModule { }

login.ts

import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {HomePage} from '../../page';


@Component({
     selector: 'page-login',
    templateUrl: 'login.html'
})


export class LoginPage {
    constructor(private navController:NavController) {
    }

    login(){
         this.navController.setRoot(HomePage);
       
    }

}

Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v6.5.0
Xcode version: Xcode 8.1 Build version 8B62

Thanks!!

Nobody is going to be able to help without seeing code, and I strongly suggest not using sudo at all when dealing with npm.

Thanks for the suggestion, I thought the code is not necessary because the build works without the option --prod

anyway this my code
app.module.ts

import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import {
  LoginPage, HomePage,
  AcademyPage, AcademyDetailPage,
  ProfilePage, ReservationPage,
  ReservationFilterPage,PaymentTabsPage,
  ActivityDetailPage
} from '../page';




@NgModule({
  declarations: [
    MyApp,
    LoginPage,
    HomePage,
    AcademyPage,
    AcademyDetailPage,
    ProfilePage,
    ReservationPage,
    ReservationFilterPage,
    PaymentTabsPage,
    ActivityDetailPage
  ],
  imports: [
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    LoginPage,
    HomePage,
    AcademyPage,
    AcademyDetailPage,
    ProfilePage,
    ReservationPage,
    ReservationFilterPage,
    PaymentTabsPage,
    ActivityDetailPage
  ],
  providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }]
})
export class AppModule { }

login.ts

import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {HomePage} from '../../page';


@Component({
     selector: 'page-login',
    templateUrl: 'login.html'
})


export class LoginPage {
    constructor(private navController:NavController) {
    }

    login(){
         this.navController.setRoot(HomePage);
       
    }

}

I suspect the problem lies in how that “page” barrel is constructed. Barrels seem like more of a hassle than a help to me, so I just don’t deal with them. Perhaps somebody who does will be able to suggest what is wrong with it.

Ok, but i put the login outside of the page and import the module directly without using the page and did not work. I will test doing the same with the others. While i was testing there was something strange, i took off the LoginModule from the app.module.ts and it keeps looking for the LoginModule.

I changed to this way instead of use the page and getting the same.

app.module.ts

import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import {LoginPage} from './pages/LoginPage';
import {HomePage} from './pages/HomePage';
import {AcademyPage} from './pages/AcademyPage';
import {AcademyDetailPage} from './pages/AcademyDetailPage';
import {ProfilePage} from './pages/ProfilePage';
import {ReservationPage} from './pages/ReservationPage';
import {ReservationFilterPage} from './pages/ReservationFilterPage';
import {PaymentTabsPage} from './pages/PaymentTabsPage';
import {ActivityDetailPage} from './pages/ActivityDetailPage';

I solve it, the problem was what you said the page. I was importing the modules in a wrong way i was putting the name of the module instead the name of the file. Thanks for your help brother.

this is the right way

import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { PaymentTabsPage } from '../pages/payment-tabs/payment-tabs';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
import { AcademyPage } from '../pages/academy/academy';
import { AcademyDetailPage } from '../pages/academy-detail/academy-detail';;
import { ProfilePage } from '../pages/profile/profile';
import { ReservationPage } from '../pages/reservation/reservation';
import { ReservationFilterPage } from '../pages/reservation-filter/reservation-filter';
import { ActivityDetailPage } from '../pages/activity-detail/activity-detail';