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

This is a basic error of angular. You can see the issue here. So the answer that is accepted till now is use share module. You can do like this:
– Create a share.module.ts
Import, declaration and export your component in this share.module.ts

import { NgModule }       from '@angular/core';
import {SharedComponentA} from "./SharedComponentA";
import {SharedComponentB} from "./SharedComponentB";

@NgModule({
    imports: [
    ],
    declarations: [
      SharedComponentA,
      SharedComponentB

    ],
    providers: [
    ],
    exports: [
      SharedComponentA,
      SharedComponentB
    ]
})
export class SharedModule {}

– If you want to use your component in a Ionic Page(lazy load page), import share module in the module of that Ionic page:

import {SharedModule } from './SharedModule';
@NgModule({
    imports: [
        SharedModule    
        //..
    ],
    //..
})

– If you want to use your component in other component or no lazy load page, import share module in your app.module.ts like above.
See more about ngModule

Leave a Comment