2017-08-17 312 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。

相关问题