【问题标题】:An error occurred while running subprocess ionic-app-scripts运行子进程 ionic-app-scripts 时出错
【发布时间】:2020-04-23 21:44:44
【问题描述】:

我是 Ionic 3 的新手。我做了一个应用程序并尝试转换为 apk。

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

ionic cordova build android --prod

页面在声明和入口组件中声明。

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

错误:

【问题讨论】:

  • 您编辑个人资料页面是 2 个模块的一部分。从 App Module 中删除它,它会工作,
  • 如果我从 app.module.ts 中删除它,它会显示错误 Did you add it to @NgModule.entryComponents?

标签: angular typescript ionic-framework build ionic3


【解决方案1】:

您将相同的组件放在多个 ngModule 数组中。尝试将其添加到上层模块中。

如果您想在多个模块中使用相同的组件,请尝试将其设为单独的模块并在该模块中导出该组件

你的.module.ts

 declarations: [
        YourComponent,
    ],
    imports: [
        CommonModule,
        ReactiveFormsModule,
    ],
    exports: [YourComponent]

编辑:1

您不能在多个模块中注册一个组件。如果您想在多个不同的模块中使用相同的组件。尝试使该组件成为一个单独的模块并将该模块导入您想要的任何位置。在您的情况下,从应用程序模块的声明中删除 EditProfilePage 并将此行添加到您的 EditProfilePageModule 中。

EditProfilePageModule.ts

exports: [EditProfilePage]

现在在您的 app.module.ts 中导入 EditProfilePage 模块

app.module.ts

imports: [
        CommonModule,
        EditProfilePageModule,
    ],

【讨论】:

  • 对不起,我没听懂。你能解释一下吗?
  • 这有助于解决您的问题吗?
  • 我工作。但现在我陷入了另一个问题。如果你能帮助我。我在网络上运行它,它在登录移动到主页后完美运行。但是在登录后的设备上,它将导航到下一页,但在后按时它将导航到再次登录。我想完成活动。表示删除前一页。提前致谢。
猜你喜欢
  • 2019-05-16
  • 2021-07-24
  • 1970-01-01
  • 1970-01-01
  • 2021-05-24
  • 2019-08-27
  • 1970-01-01
  • 2019-04-14
  • 2018-12-05
相关资源
最近更新 更多