发生了一个错误,正在运行子进程 ionic-app-scripts。

huangapple go评论86阅读模式
英文:

An error occurred while running subprocess ionic-app-scripts

问题

我是Ionic 3的新手。我已经完成了一个应用程序并尝试将其转换为APK。

我使用以下CLI生成调试(或测试)android-debug.apk:

ionic cordova build android --prod

declarationsentryComponents中声明了页面。

这是我的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 {}

错误:

发生了一个错误,正在运行子进程 ionic-app-scripts。

英文:

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:

发生了一个错误,正在运行子进程 ionic-app-scripts。

答案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,
    ],

huangapple
  • 本文由 发表于 2020年1月6日 18:36:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/59610564.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定