我有在其上欲执行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我的坏,我只是错过了它,而复制粘贴。它实际上存在于源代码 –