2017-04-24 44 views
0

我最近迁移了我的项目以使用Angular CLI来打包我的项目。它工作正常使用“NG构建”但是当我尝试使用“NG构建--prod”(又使用角AOT和其他额外的步骤),我得到这些错误:Angular CLI(AOT)给出错误:ERROR in无法确定类的模块

ERROR in Cannot determine the module for class CustomDialog in F:/depot/depot/code/main/web/CedarsReport/src/a 
pp/dialogs/customDialog.ts! Add CustomDialog to the NgModule to fix it. 
Cannot determine the module for class ConfirmDialog in F:/depot/depot/code/main/web/CedarsReport/src/app/dialo 
gs/confirmDialog.ts! Add ConfirmDialog to the NgModule to fix it. 
Cannot determine the module for class EditUserDialog in F:/depot/depot/code/main/web/CedarsReport/src/app/dial 
ogs/editUserDialog.ts! Add EditUserDialog to the NgModule to fix it. 
Cannot determine the module for class LoginDialog in F:/depot/depot/code/main/web/CedarsReport/src/app/dialogs 
/loginDialog.ts! Add LoginDialog to the NgModule to fix it. 
Cannot determine the module for class EditAllControlsDlg in F:/depot/depot/code/main/web/CedarsReport/src/app/ 
dialogs/editAllControlsDlg.ts! Add EditAllControlsDlg to the NgModule to fix it. 
Cannot determine the module for class EmptyTemplateDlg in F:/depot/depot/code/main/web/CedarsReport/src/app/di 
alogs/emptyDialogTemplate.ts! Add EmptyTemplateDlg to the NgModule to fix it. 
Cannot determine the module for class PopupSkeleton in F:/depot/depot/code/main/web/CedarsReport/src/app/direc 
tives/popupSkeleton.ts! Add PopupSkeleton to the NgModule to fix it. 

然而,大多数的这些文件是在一个模块调用CRDialogs.module.ts引用:

import { NgModule }  from '@angular/core'; 
import { CommonModule } from '@angular/common'; // ngFor, ngIf, ngStyle, and so on 

import { Ng2Bs3ModalModule, ModalComponent } from 'ng2-bs3-modal/ng2-bs3-modal'; 

    // Some dialogs use directives we've created 
import { CRDirectives } from '../directives/CRDirectives.module'; 

    // What we want to declare and export. Also, anything in 'imports' below is made available to all of these components 
import { ChangePasswordDialog } from "./changePasswordDialog" 
import { ConfirmDialog } from "./ConfirmDialog" 
import { CreateShortcutDialog } from "./CreateShortcutDialog" 
import { CustomDialog } from "./CustomDialog" 
import { EditControlDlg } from "./EditControlDlg" 
import { EditSectionDlg } from "./EditSectionDialog" 
import { EditSitesDialog } from "./EditSitesDialog" 
import { StandardFieldDialog } from "./editStandardFieldDialog" 
import { EditUserDialog } from "./EditUserDialog" 
import { ErrorsDialog } from "./ErrorsDialog" 
import { GenericListDlg } from "./GenericListDialog" 
import { LoginDialog } from "./LoginDialog" 
import { ReferringPhysDialog } from "./ReferringPhysDialog" 
import { SignReportDlg } from "./SignReportDlg" 


@NgModule(
{ 
    imports: [CommonModule, CRDirectives, Ng2Bs3ModalModule],  // Other modules to import 

    declarations: [ 
     ChangePasswordDialog, ConfirmDialog, CreateShortcutDialog, CustomDialog, EditControlDlg, EditSectionDlg, EditSitesDialog, 
     EditUserDialog, StandardFieldDialog, ErrorsDialog, GenericListDlg, LoginDialog, ReferringPhysDialog, SignReportDlg 
    ], 

    exports: [ 
     ChangePasswordDialog, ConfirmDialog, CreateShortcutDialog, CustomDialog, EditControlDlg, EditSectionDlg, EditSitesDialog, 
     EditUserDialog, StandardFieldDialog, ErrorsDialog, GenericListDlg, LoginDialog, ReferringPhysDialog, SignReportDlg 
    ] 
}) 

export class CRDialogs {} 

而反过来该模块被引用在我app.module.ts:

import { CRGlobals } from "./globals" 

[...] 

@NgModule({ 
    declarations: [ 
     CSReportMain, 
     AppTestTemp 
    ], 
    imports: [ 
     BrowserModule, 
     FormsModule, 
     HttpModule, 
     CRDirectives, 
     **CRDialogs,** 
     CRPages, 

     [...] 
    ], 
    providers: [ 
     CRGlobals 
    ], 
    bootstrap: [CSReportMain] 
}) 

这main.ts:

import { enableProdMode } from '@angular/core'; 
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 

import { AppModule } from './app/app.module'; 
import { environment } from './environments/environment'; 

if (environment.production) { 
    enableProdMode(); 
} 

platformBrowserDynamic().bootstrapModule(AppModule); 

那么,为什么我会得到这个错误?

+0

你可以发表你的主要的app.model.ts正确的进口。 ts?或无论你使用platformBrowserDynamic()。bootstrapModule(...);我假设它看起来像这样:platformBrowserDynamic()。bootstrapModule(AppModule); ? –

+0

当然可以。原始帖子已更新。 (参见结束) –

回答

1

在app.module.ts你有没有尝试做实际的导入,而不是将它们引用回CRDialogs.module.ts 我还注意到,在main.ts中,你只导入app.module.ts ,你可以尝试先导入CRDialogs.module.ts,然后再在app.module.ts中进行导入。

我新的角度,我只是固定一个类似的问题,我的问题是,我没有做我希望这有助于

+0

这实际上是什么意思? “尝试执行实际的导入,而不是将它们引用回CRDialogs.module.ts” – Cole

相关问题