代码之家  ›  专栏  ›  技术社区  ›  Akanksha Gaur

相对路径问题-TypeScript编译器在Windows和Linux上的行为不同

  •  1
  • Akanksha Gaur  · 技术社区  · 9 年前

    我用过 relative Paths 导入在我的 Angular2 TypeScript 应用

    实例 ( Source Code )

    import {Http} from 'angular2/http';
    import {Injectable} from 'angular2/core';
    import {Person} from '../core/Person';  
    

    这在windows(tsc v1.7.5)上编译良好,但无法在Linux上加载。

    问题:

    1. 为什么在linux上会这样?
    2. 有没有一种标准的方法在typescript中声明模块的路径?

    tsconfig.json

    {
      "compilerOptions": {
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
      },
      "exclude": [
        "node_modules",
         "wwwroot/lib"
      ]
    }
    

    Ubuntu 14.04出错

    wwwroot/app/peopes/people.service。ts(3,22):错误TS2307:找不到模块“../core/Person”。 wwwroot/app/routes.config。ts(1,22):错误TS2307:找不到模块'./home/home'。 wwwroot/app/routes.config。ts(2,23):错误TS2307:找不到模块“./about/about”。 wwwroot/app/routes.config。ts(3,24):错误TS2307:找不到模块“./peopes/people”。 wwwroot/app/routes.config。ts(4,30):错误TS2307:找不到模块“./peopes/PersonDetail”。

    从github上的源代码可以看到,Person。ts包含位于wwwroot\app\core\person.ts中的类person

    请帮助我解决这个问题。提前谢谢。

    1 回复  |  直到 9 年前
        1
  •  7
  •   Akanksha Gaur    9 年前

    我发现了问题。

    Windows忽略目录中的大小写&文件名,而linux没有。

    在将所有文件夹和文件名保存为小写并在导入中复制后。它编译成功。

    推荐文章