我有在其上欲執行AOT構建。應用使用@angular/cli
創建的角(4.3.2)應用程序。我有兩個組成部分與腳手架和ng generate
其中兩個被包括作爲聲明的模塊:角AOT編譯錯誤「不能確定模塊,用於類元器件'
import {PrivateComponent} from './private.component/private.component';
NgModule({
imports: [
// other imports
PrivateRoutingModule
],
declarations: [
...some other components,
PrivateComponent,
AppTopBarComponent
]
// other stuff
})
export class PrivateModule {}
私人分量也被在模塊的路由中使用的:
const routes: Routes = [
{path: '', component: PrivateComponent, children: // other components}
]
@NgModule({
imports: [RouterModule.forChild(routes)] // this is the Angular built-in router module
})
export class PrivateRoutingModule {}
通知路由是如何在另一個模塊中定義並導入到PrivateModule
AppTopBarComponent
用於PrivateComponent's
模板中。所以這兩個都被使用和聲明。但是當我使用"node_modules/.bin/ngc" -p tsconfig-aot.json
(我在Windows 10上)時,出現此錯誤消息: Cannot determine the module for class PrivateComponent in (path-to-project)/src/app/pages/private/private.component/private.component.ts! Add PrivateComponent to the NgModule to fix it.
Cannot determine the module for class AppTopBarComponent in (path-to-project)/src/app/pages/private/app.topbar.component.ts! Add AppTopBarComponent to the NgModule to fix it.
。我的tsconfig-aot.json
文件與Angular AOT build guide中的完全相同。
值得一提的我遇到的幾個問題在這個問題上,但問題主要是未使用的組件。我的實際使用。 –
您忘記了在'./private.component/private.component'的導入導入{PrivateComponent}中添加PrivateComponent; – Vega
@Vega我的壞,我只是錯過了它,而複製粘貼。它實際上存在於源代碼 –