Reputation: 323
i got a new error with ionic when we create a build for production using command
ionic cordova build --prod
it always gives an error at the point of ngc started
Running app-scripts build: --prod
[15:00:23] build prod started ...
[15:00:23] clean started ...
[15:00:23] clean finished in 36 ms
[15:00:23] copy started ...
[15:00:23] ngc started ...
Error: Type DashboardPage in /Users/sunny/Desktop/Apps/IONIC/MintOld/src/pages/dashboard/dashboard.ts
is part of the declarations of 2 modules: AppModule in
/Users/sunny/Desktop/Apps/IONIC/MintOld/src/app/app.module.ts and
DashboardPageModule in /Users/sunny/Desktop/Apps/IONIC/MintOld/src/pages/dashboard/dashboard.module.ts!
Please consider moving DashboardPage in
/Users/sunny/Desktop/Apps/IONIC/MintOld/src/pages/dashboard/dashboard.ts to a
higher module that imports AppModule in
/Users/sunny/Desktop/Apps/IONIC/MintOld/src/app/app.module.ts and
DashboardPageModule in /Users/sunny/Desktop/Apps/IONIC/MintOld/src/pages/dashboard/dashboard.module.ts.
You can also create a new NgModule that exports and includes DashboardPage in
/Users/sunny/Desktop/Apps/IONIC/MintOld/src/pages/dashboard/dashboard.ts
then import that NgModule in AppModule in
/Users/sunny/Desktop/Apps/IONIC/MintOld/src/app/app.module.ts
and DashboardPageModule in /Users/sunny/Desktop/Apps/IONIC/MintOld/src/pages/dashboard/dashboard.module.ts.
Upvotes: 0
Views: 1058
Reputation: 740
It's because of you have declared the DashboardPage in two modules, If you are using this.navCtrl.push("DashboardPage")
, then remove DashboardPage from app.module.ts file under declatrations, or if you are using this.navCtrl.push(DashboardPage)
, then delete the dashboard-page-module file.
Upvotes: 0
Reputation: 935
I got the same error too. I just solved it by closing all ionic
tasks running in parallel and deleting the www
folder from my project folder.
I then just ran
ionic cordova build android
and then
ionic cordova build android --prod --release
And it worked. I don't know how / why , but doing it like this I did not get that error
Upvotes: 0
Reputation: 6421
As the error says you're importing your module 2 times, maybe you have done lazy loading pages and forgot to delete the import of your module from app.module.ts
So if you're using lazy loading modules, go to your app.module.ts
and look for your imported DashboardPage
in Declarations
and/or entryComponents
array, if they're there just delete the DashboardPage from them.
If you're not lazy loading you'll need to delete the dashboard.module.ts
file.
You can't have the page module imported to a same level @NgModule
, that's what you're doing wrong.
Hope this helps.
Upvotes: 1