无法在X.ts中确定X类的模块!将X添加到NgModule以修复ionic2中的错误

use*_*867 7 ionic2 ionic2-providers ionic3 angular

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

ionic cordova run android --prod --release

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

ionic cordova run android
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

错误:无法确定C:/test/src/pages/cart/cart-items.ts中类CartItemsPage的模块!将CartItemsPage添加到NgModule以修复它.无法确定C:/test/src/pages/items/items.ts中类ItemsPage的模块!将ItemsPage添加到NgModule以修复它.无法在C:/test/src/pages/user-home/user-home.ts中确定类UserHomePage的模块!将用户主页添加到NgModule以修复它.无法确定C语言中的ForgotPasswordPage类的模块:/ test/src/pages/forgot-password/forgot-pas sword.ts!将ForgotPasswordPage添加到NgModule以修复它.无法在C:/test/src/pages/login/login.ts中确定类LoginPage的模块!将LoginPage添加到NgModule以修复它.无法在C:/test/src/pages/signup/signup.ts中确定类SignupPage的模块!将SignupPage添加到NgModule以修复它.无法在C:/test/src/pages/welcome/welcome.ts中确定欢迎页面类的模块!将WelcomePa ge添加到NgModule以修复它.无法在C:/test/src/pages/pincode/pincode.ts中确定PincodePage类的模块!将PincodePa ge添加到NgModule以修复它.无法在C:/test/src/pages/app-home/app-home.ts中确定AppHomePage类的模块!将AppHome页面添加到NgModule以修复它.无法在C:/test/src/pages/profile/profile.ts中确定类ProfilePage的模块!将ProfilePa ge添加到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文件中以进行修复.无法在C:/test/src/utils/pipes/RemoveUnderscore.ts中确定类RemoveUnderscorePipe的模块!将RemoveUnderscorePipe添加到NgModule以修复它.

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

// 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 {
}
Run Code Online (Sandbox Code Playgroud)

如果你看到我的app.module.ts,我已经为entrycomponents和声明添加了组件和管道.生产标志有什么我遗漏的吗?我该如何解决这个问题?

Ram*_*Ram 11

详细说明@[Thom Kiesewetter] 的回答

它也可以是在模块路由或其他任何地方使用的路径大小写问题参考

例如路径是

进口{EmployeeComponent}从“./ ë ntities / employee.component”;

代替

从“./ e ntities/employee.component”导入{EmployeeComponent} ;

其中真正的路径是“ é ntities”,而不是“ ê ntities”


Tho*_*ter 8

这也可能是文件名大小写问题。参见https://github.com/angular/angular-cli/issues/10732


use*_*867 5

将声明更改为如下所示的页面并且它起作用了。

declarations: pages
Run Code Online (Sandbox Code Playgroud)

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