Ionic build --prod error: Type ... in ... is part of the declarations of 2 modules:

Thanks @monoko26333 .
This solve the issue

@ Profihorst1 and @ anespa are right.

Do not delete page modules files, remove their page components imports in app.module.ts, import page modules to app.module.ts

FWIW, I disagree with the lazy loading cheerleaders. I still don’t think the problem of code duplication has been solved yet, which means for apps that share components amongst many pages, lazy loading adds needless complexity for bloated app binaries.

This solved the problem for me! Thanks @arnoldparge!

este problema lo resolvi quitando components.module.ts de la carpeta components ya que hacia referencia en @NgModule({ 2 veces! asi logre solucionarlo

1 Like

thank you, this solved my problem

it works. thanks a lot . keep coding.

sii! asi tambien lo solucione.
it works fine for me
In my case: this is my component that is repeating ModalFilterOptionPage :
import { NgModule } from ‘@angular/core’;
import { CommonModule } from ‘@angular/common’;
import { Routes, RouterModule } from ‘@angular/router’;

import { IonicModule } from ‘@ionic/angular’;

import { ReactiveFormsModule } from ‘@angular/forms’;

const routes: Routes = [
path: ‘’,
/* component: ModalFilterOptionPage remove it */

imports: [
]/* ,
declarations: [ModalFilterOptionPage] remove it*/
export class ModalFilterOptionPageModule {}

Then, only add it in your app module:

declarations: [
entryComponents: [

it works for me!

I ran into the same problem while generating a pipe. So, if anybody came here with a similar problem creating a custom pipe, here’s what I’ve done to solve it:

  1. I added PipesModule as an Import (not declaration) in app.module.ts
  2. I added PipesModule as an Import (not declaration) in page.module.ts (the page where I am using the pipe)
  3. The PipesModule file automatically generated by CLI (3.9.2) declares and exports the custom pipe I wanted to use.

This way, I could build the app without any AoT compiling errors. Maybe there’s a more elegant and proper way to do this, but this has solved my problem.

I signed up just to thank you