Cannot build application ionic (latest version)


#1

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:

https://gyazo.com/f5d26cb79d7e7115e453fce41b6e3dea

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


#2

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.


#3

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.


#5

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.


#6

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


#7

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.


#8

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


#9

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.


#10

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


#11

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