我在ng serve命令後在Angular 4項目中遇到錯誤。Angular 4錯誤:有多個模塊名稱僅在套管中有所不同
./src/app/Utils/config.service.ts There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * D:\ANGULAR\siteprice.org\node_modules\@ngtools\webpack\src\index.js!D:\ANGULAR\siteprice.org\src\app\Utils\config.service.ts Used by 1 module(s), i. e. D:\ANGULAR\siteprice.org\node_modules\@ngtools\webpack\src\index.js!D:\ANGULAR\siteprice.org\src\app\utils\email.service.ts * D:\ANGULAR\siteprice.org\node_modules\@ngtools\webpack\src\index.js!D:\ANGULAR\siteprice.org\src\app\utils\config.service.ts Used by 2 module(s), i. e. D:\ANGULAR\siteprice.org\node_modules\@ngtools\webpack\src\index.js!D:\ANGULAR\siteprice.org\src\app\app.module.ts
config.service.ts文件:
import { Injectable } from '@angular/core';
@Injectable()
export class ConfigService {
_apiURI : string;
constructor() {
this._apiURI = 'http://www.example.com/xyz/api/';
}
getApiURI() {
return this._apiURI;
}
getApiHost() {
return this._apiURI.replace('api/','');
}
}
email.service.ts:
import { Injectable } from '@angular/core';
import { Http, Response, Headers } from '@angular/http';
import {Observable} from 'rxjs';
import 'rxjs/add/operator/map';
import { ConfigService } from '../Utils/config.service';
import { Email } from '../Models/email';
@Injectable()
export class EmailService {
apiRoot: string = '';
constructor(private http: Http, private configService: ConfigService) {
this.apiRoot = configService.getApiURI();
}
我檢查了服務名稱的外殼,他們是正確的。