ng build --prod无法确定X类的模块!将ThreadListTabsComponent添加到NgModule进行修复 [英] ng build --prod Cannot determine the module for class X! Add ThreadListTabsComponent to the NgModule to fix it
问题描述
我正在尝试构建Angular 5应用,但出现错误:
I'm trying to build my Angular 5 app, and I'm getting the error:
无法确定类ThreadListTabsComponent中的模块 /home/brightwater/Differ/src/app/thread-lists/thread-lists.component.ts! 将ThreadListTabsComponent添加到NgModule进行修复.
Cannot determine the module for class ThreadListTabsComponent in /home/brightwater/Differ/src/app/thread-lists/thread-lists.component.ts! Add ThreadListTabsComponent to the NgModule to fix it.
这令人困惑,因为我正在模块中导入有问题的组件:
This is confusing because I'm importing the offending component in the module:
thread-lists.module.ts :
import { OtherModules } from './modules-everywhere';
import { NgModule } from '@angular/core'
import { SomeOtherComponents } from './other-components.component';
import { ThreadListTabsComponent } from './thread-list-tabs.component';
@NgModule({
imports:
[
OtherModules
],
declarations: [
OtherComponents,
ThreadListTabsComponent
],
exports: [
OtherComponents,
ThreadListTabsComponent
],
providers: [ ThreadListsService ]
})
export class ThreadListsModule { }
以下是组件:
thread-list-tabs.component.ts
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Router } from '@angular/router';
import { ThreadListsService } from './thread-lists.service';
@Component({
moduleId: module.id,
selector: 'thread-list-tabs',
templateUrl: 'thread-list-tabs.component.html',
styleUrls: ['thread-list-tabs.component.css']
})
export class ThreadListTabsComponent {
// Stuff this component does
}
app.module.ts
import { NgModule } from '@angular/core'
import { ThreadListsModule } from './thread-lists/thread-lists.module'
import { OtherModules } from './other.modules'
import { AppComponent } from './app.component'
@NgModule({
imports: [
OtherModules,
ThreadListsModule
],
declarations: [
AppComponent
],
providers: [ SomeService ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
有什么我想念的吗?
推荐答案
这看起来像文件名大小写问题,请参见 Angular git repo(https://github.com/angular/angular-cli/issues/10732)中描述的问题
This looks like a filename casing problem, see the issue described on angular git repo (https://github.com/angular/angular-cli/issues/10732)
这篇关于ng build --prod无法确定X类的模块!将ThreadListTabsComponent添加到NgModule进行修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!