问题描述
我正在尝试构建我的 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 以修复它.
这令人困惑,因为我在模块中导入了违规组件:
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 以修复它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!