加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 4错误:有多个模块的名称只有外壳不同

发布时间:2020-12-17 17:23:28 所属栏目:安全 来源:网络整理
导读:ng服务命令后,我在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.
ng服务命令后,我在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:ANGULARsiteprice.orgnode_modules@ngtoolswebpacksrcindex.js!D:ANGULARsiteprice.orgsrcappUtilsconfig.service.ts
Used by 1 module(s),i. e.
D:ANGULARsiteprice.orgnode_modules@ngtoolswebpacksrcindex.js!D:ANGULARsiteprice.orgsrcapputilsemail.service.ts
* D:ANGULARsiteprice.orgnode_modules@ngtoolswebpacksrcindex.js!D:ANGULARsiteprice.orgsrcapputilsconfig.service.ts
Used by 2 module(s),i. e.
D:ANGULARsiteprice.orgnode_modules@ngtoolswebpacksrcindex.js!D:ANGULARsiteprice.orgsrcappapp.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();
  }

我检查了服务名称的大小写,它们是正确的.

解决方法

我发现了这个问题,我认为它可能是CLI中的一个错误.

Utils文件夹名称应为utils.所以第一个字母是小写的.
我的Windows目录中的utils文件夹是用小写创建的.
所以我改变了这个:

import { ConfigService } from '../Utils/config.service';

至:

import { ConfigService } from '../utils/config.service';

编辑:

看起来这是一个已知问题,其中一个建议的解决方案是使用kebap案例文件,windows中的文件夹名称.

https://github.com/AngularClass/angular-starter/issues/926

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读