Cannot build application ionic (latest version)

I am using command ionic cordova build android --prod.
I am getting this as error:

Error: Type LoginPage in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/pages/login/login.ts is part of the declarations of 2 modules: AppModule in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/app/
app.module.ts and LoginPageModule in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/pages/login/login.module.ts! Please consider moving LoginPage in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/pag
es/login/login.ts to a higher module that imports AppModule in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/app/app.module.ts and LoginPageModule in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/p
ages/login/login.module.ts. You can also create a new NgModule that exports and includes LoginPage in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/pages/login/login.ts then import that NgModule in Ap
pModule in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/app/app.module.ts and LoginPageModule in C:/Users/aksha/Desktop/ionic_apps/askGanesha/src/pages/login/login.module.ts.

I have a LoginPage in my app, i didn’t understand what the error says please help.

Here is the structure of my application:

Please help, I have to submit app in like 10 days :frowning:

It sounds like you’ve imported LoginPage in both the LoginPageModule as well as your app module.

If you’re using lazy loading then you need to remove it from your app module.

Thanks for reply.
I am not using lazy loading and didn’t even touched LoginPageModule ionic
generated that by itself. It is necessary or can I remove it?
I have just imported LoginPage into app.module.ts and added it to
declarations and entryComponents array.

Ah, then yeah you can remove it. If you have other modules for pages you’ll want to remove them too. The Ionic CLI assumes you’ll be using lazy loading, and thus generates modules for you.

But then why does it not show me same error for all other pages? I have page specific modules with each page.

My first guess is that it simply runs into this error and then stops without looking for other errors. I’m not certain about it though.

Please try the command …cordova build android --prod…
This works well for my case.

This has absolutely nothing to do with the problem @akshatbhargava123 has. Using the cordova command directly even doesn’t build the Ionic project at all, where he/she has the problem.

@akshatbhargava123 You are not supposed to add it to imports. It is to be added to entryComponents.

sorry I didn’t meant imports, I added them to declarations and entryComponents.