2017-08-17 369 views
0

當我們爲生產中使用命令創建構建我得到離子新的錯誤離子科爾多瓦構建Android --prod

ionic cordova build --prod 

它總是給人一個錯誤在NGC點開始

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. 

回答

0

由於錯誤說這是您導入模塊2次,也許你已經做懶加載頁面時忘了從app.module.ts

所以刪除模塊的進口如果你使用懶惰加載模塊,請轉到您的app.module.ts,並在Declarations和/或entryComponents陣列中查找導入的DashboardPage陣列,如果它們在那裏只是從它們中刪除DashboardPage。

如果你不是懶惰加載,你需要刪除dashboard.module.ts文件。

您不能將頁面模塊導入到同一級別@NgModule,那就是您做錯了。

希望這會有所幫助。

0

我也得到了同樣的錯誤。我通過關閉並行運行的所有ionic任務並從我的項目文件夾中刪除www文件夾來解決此問題。

然後我剛跑

ionic cordova build android

然後

ionic cordova build android --prod --release

和它的工作。我不知道如何/爲什麼,但這樣做這樣我沒有得到這個錯誤

0

這是如果你正在使用this.navCtrl.push("DashboardPage")因爲你已經宣佈DashboardPage兩個模塊,然後取出DashboardPage from app.module.ts file in declatrations,or if you are using this.navCtrl.push(DashboardPage),then delete the dashboard-page-module file。