相对路径问题 - TypeScript 编译器在 Windows 和 Linux 上的行为不同
Relative path Issue - TypeScript compiler behaving differently on Windows vs Linux
我已经使用 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 上加载。
Questions:
- Why is this behaving so on linux?
- Is there a standard way to declare path of modules in 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/people/people.service.ts(3,22): error TS2307: Cannot find module '../core/Person'.
wwwroot/app/routes.config.ts(1,22): error TS2307: Cannot find module './home/Home'.
wwwroot/app/routes.config.ts(2,23): error TS2307: Cannot find module './about/About'.
wwwroot/app/routes.config.ts(3,24): error TS2307: Cannot find module './people/People'.
wwwroot/app/routes.config.ts(4,30): error TS2307: Cannot find module './people/PersonDetail'.
从 github 上的源代码可以看出,Person.ts 包含位于 wwwroot\app\core\Person.ts
的 class 人
请帮我解决这个问题。提前致谢。
我发现了问题。
Windows ignores case in directory & file names whereas linux does not.
在保留所有文件夹和文件名小写并在导入中复制它们之后。编译成功。
我已经使用 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 上加载。
Questions:
- Why is this behaving so on linux?
- Is there a standard way to declare path of modules in 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/people/people.service.ts(3,22): error TS2307: Cannot find module '../core/Person'. wwwroot/app/routes.config.ts(1,22): error TS2307: Cannot find module './home/Home'. wwwroot/app/routes.config.ts(2,23): error TS2307: Cannot find module './about/About'. wwwroot/app/routes.config.ts(3,24): error TS2307: Cannot find module './people/People'. wwwroot/app/routes.config.ts(4,30): error TS2307: Cannot find module './people/PersonDetail'.
从 github 上的源代码可以看出,Person.ts 包含位于 wwwroot\app\core\Person.ts
的 class 人请帮我解决这个问题。提前致谢。
我发现了问题。
Windows ignores case in directory & file names whereas linux does not.
在保留所有文件夹和文件名小写并在导入中复制它们之后。编译成功。