英文:
An error occurred while running subprocess ionic-app-scripts
问题
我是Ionic 3的新手。我已经完成了一个应用程序并尝试将其转换为APK。
我使用以下CLI生成调试(或测试)android-debug.apk:
ionic cordova build android --prod
在declarations
和entryComponents
中声明了页面。
这是我的app.module.ts:
@NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage,
MobileScreenPage,
OtpScreenPage,
RegisterPage,
ForgotPasswordPage,
EditProfilePage,
MemberDetailPage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage,
MobileScreenPage,
OtpScreenPage,
RegisterPage,
ForgotPasswordPage,
EditProfilePage,
MemberDetailPage
],
providers: [
StatusBar,
SplashScreen,
{ provide: ErrorHandler, useClass: IonicErrorHandler },
AuthServiceProvider
]
})
export class AppModule {}
错误:
英文:
I am a newbie to Ionic 3. I have done an application and tried to convert to apk.
I am generating debug (or testing) android-debug.apk using below CLI :
ionic cordova build android --prod
Page declares in declarations and entryComponents.
This is my app.module.ts
@NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage,
MobileScreenPage,
OtpScreenPage,
RegisterPage,
ForgotPasswordPage,
EditProfilePage,
MemberDetailPage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage,
LoginPage,
MobileScreenPage,
OtpScreenPage,
RegisterPage,
ForgotPasswordPage,
EditProfilePage,
MemberDetailPage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AuthServiceProvider
]
})
export class AppModule {}
Error:
答案1
得分: 1
您正在将相同的组件添加到多个ngModule数组中。尝试将其添加到更高级别的模块中。
如果您想要在多个模块中使用相同的组件,请尝试将其制作成一个单独的模块,并在该模块中导出该组件。
your.module.ts
declarations: [
YourComponent,
],
imports: [
CommonModule,
ReactiveFormsModule,
],
exports: [YourComponent]
Edit: 1
您不能在多个模块中注册同一个组件。如果您希望在多个不同的模块中使用相同的组件,请尝试将该组件制作成一个单独的模块,并在需要的地方导入该模块。在您的情况下,从应用程序模块的declarations中删除EditProfilePage,并在EditProfilePageModule中添加以下行。
EditProfilePageModule.ts
exports: [EditProfilePage]
现在在您的app.module.ts中导入EditProfilePage模块。
app.module.ts
imports: [
CommonModule,
EditProfilePageModule,
],
英文:
You are putting same component in multiple ngModule array. Try to add this in upper level module.
If you want to use same component in multiple modules try to make it a separate module and export that component in that module
your.module.ts
declarations: [
YourComponent,
],
imports: [
CommonModule,
ReactiveFormsModule,
],
exports: [YourComponent]
Edit: 1
You can not register one component in multiple modules. If you want same component in multiple different modules. Try to make make that component a separate module and import that module where ever you want. In your case, remove EditProfilePage from app module's declarations and add this line in your EditProfilePageModule.
EditProfilePageModule.ts
exports: [EditProfilePage]
Now in your app.module.ts import the EditProfilePage module
app.module.ts
imports: [
CommonModule,
EditProfilePageModule,
],
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论