无法确定 X.ts 中 X 类的模块!将 X 添加到 NgModule 以修复 ionic2 中的错误 [英] Cannot determine the module for class X in X.ts! Add X to the NgModule to fix it error in ionic2

查看:12
本文介绍了无法确定 X.ts 中 X 类的模块!将 X 添加到 NgModule 以修复 ionic2 中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用以下命令构建我的应用程序时遇到问题:

I am facing an issue when I try to build my app using the following command :

ionic cordova run android --prod --release

如果我运行如下命令,一切都会正常运行:

Everything runs fine if I run the command as below:

ionic cordova run android

我得到的错误是:

错误:无法确定类 CartItemsPage 的模块C:/test/src/pages/cart/cart-items.ts!将 CartItemsPage 添加到NgModule 来修复它.无法确定类 ItemsPage 的模块C:/test/src/pages/items/items.ts!将 ItemsPage 添加到 NgModule 到修理它.无法确定类 UserHomePage 的模块C:/test/src/pages/user-home/user-home.ts!将用户主页添加到NgModule 来修复它.无法确定类的模块C:/test/src/pages/forgot-password/forgot-pas 中的 ForgotPasswordPage剑.ts!将 ForgotPasswordPage 添加到 NgModule 以修复它.不能确定类 LoginPage 的模块C:/test/src/pages/login/login.ts!将 LoginPage 添加到 NgModule 到修理它.无法确定类 SignupPage 的模块C:/test/src/pages/signup/signup.ts!将 SignupPage 添加到 NgModule 到修理它.无法确定类 WelcomePage 的模块C:/test/src/pages/welcome/welcome.ts!将 WelcomePage 添加到 NgModule要解决这个问题.无法确定类 PincodePage 的模块C:/test/src/pages/pincode/pincode.ts!将 PincodePage 添加到 NgModule要解决这个问题.无法确定类 AppHomePage 的模块C:/test/src/pages/app-home/app-home.ts!将 AppHome 页面添加到NgModule 来修复它.无法确定类 ProfilePage 的模块在 C:/test/src/pages/profile/profile.ts 中!将 ProfilePage 添加到NgModule 来修复它.无法确定类的模块C:/test/src/pages/myorders/order-detail.ts 中的 OrderDetailPage!添加OrderDetailPage 到 NgModule 来修复它.无法确定模块对于 C:/test/src/pages/myorders/myorders.ts 中的 MyOrdersPage 类!添加MyOrde rsPage 到 NgModule 来修复它.无法确定模块对于 C:/test/src/pages/logout/logout.ts 中的类 LogoutPage!添加LogoutPage 到 NgModule 来修复它.无法确定模块C:/test/src/app/app.component.ts 中的 MyApp 类!将 MyApp 添加到NgModu le 修复它.无法确定类的模块C:/test/src/utils/pipes/RemoveUnderscore.t s 中的 RemoveUnderscorePipe!将 RemoveUnderscorePipe 添加到 NgModule 以修复它.

Error: Cannot determine the module for class CartItemsPage in C:/test/src/pages/cart/cart-items.ts! Add CartItemsPage to the NgModule to fix it. Cannot determine the module for class ItemsPage in C:/test/src/pages/items/items.ts! Add ItemsPage to th e NgModule to fix it. Cannot determine the module for class UserHomePage in C:/test/src/pages/user-home/user-home.ts! Add User HomePage to the NgModule to fix it. Cannot determine the module for class ForgotPasswordPage in C:/test/src/pages/forgot-password/forgot-pas sword.ts! Add ForgotPasswordPage to the NgModule to fix it. Cannot determine the module for class LoginPage in C:/test/src/pages/login/login.ts! Add LoginPage to th e NgModule to fix it. Cannot determine the module for class SignupPage in C:/test/src/pages/signup/signup.ts! Add SignupPage t o the NgModule to fix it. Cannot determine the module for class WelcomePage in C:/test/src/pages/welcome/welcome.ts! Add WelcomePa ge to the NgModule to fix it. Cannot determine the module for class PincodePage in C:/test/src/pages/pincode/pincode.ts! Add PincodePa ge to the NgModule to fix it. Cannot determine the module for class AppHomePage in C:/test/src/pages/app-home/app-home.ts! Add AppHome Page to the NgModule to fix it. Cannot determine the module for class ProfilePage in C:/test/src/pages/profile/profile.ts! Add ProfilePa ge to the NgModule to fix it. Cannot determine the module for class OrderDetailPage in C:/test/src/pages/myorders/order-detail.ts! Add OrderDetailPage to the NgModule to fix it. Cannot determine the module for class MyOrdersPage in C:/test/src/pages/myorders/myorders.ts! Add MyOrde rsPage to the NgModule to fix it. Cannot determine the module for class LogoutPage in C:/test/src/pages/logout/logout.ts! Add LogoutPage t o the NgModule to fix it. Cannot determine the module for class MyApp in C:/test/src/app/app.component.ts! Add MyApp to the NgModu le to fix it. Cannot determine the module for class RemoveUnderscorePipe in C:/test/src/utils/pipes/RemoveUnderscore.t s! Add RemoveUnderscorePipe to the NgModule to fix it.

但我已将所有页面和管道添加到 app.module.ts,如下所示:

but I have added all my pages and pipes to app.module.ts as below :

// Imports

// The translate loader needs to know where to load i18n files
// in Ionic's static asset pipeline.
export function HttpLoaderFactory(http: Http) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}


let pages:any = [
  MyApp,
  LoginPage,
  UserHomePage,
  SignupPage,
  AppHomePage,
  WelcomePage,
  ItemsPage,
  CartItemsPage,
  ProfilePage,
  MyOrdersPage,
  OrderDetailPage,
  ForgotPasswordPage,
  PincodePage,
  LogoutPage
];

let pipes = [RemoveUnderscorePipe];

export function declarations() {
  return pages.concat(pipes);
}

export function entryComponents() {
  return pages;
}

export function providers() {
  return [
    Api,
    ItemsService,
    UserService,
    ToastService,
    CartService,
    OrdersService,
    TokenService,
    Camera,
    GoogleMaps,
    SplashScreen,
    StatusBar,

    // Keep this to enable Ionic's runtime error handling during development
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ];
}


@NgModule({
  declarations: declarations(),
  imports: [
    BrowserModule,
    HttpModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [Http]
      }
    }),
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: entryComponents(),
  providers: providers()
})
export class AppModule {
}

如果您看到我的 app.module.ts,我已将组件和管道添加到 entrycomponents 和声明.生产标志有什么我缺少的吗?我该如何解决这个问题?

If u see my app.module.ts, I have added components and pipes to entrycomponents and declarations. Is there anything I am missing for production flag. How can I resolve this issue?

推荐答案

将声明更改为如下页面,并且成功了.

Changed declarations to pages like below and it worked.

declarations: pages

我得到了答案:https://forum.ionicframework.com/t/error-while-running-the-ionic3-app-in-production-mode/106294

这篇关于无法确定 X.ts 中 X 类的模块!将 X 添加到 NgModule 以修复 ionic2 中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆