我使用 relative Paths
导入在 Angular2
和 TypeScript
应用程序中创建的模块 .
Example (Source Code)
import {Http} from 'angular2/http';
import {Injectable} from 'angular2/core';
import {Person} from '../core/Person';
这在windows上编译很好(tsc v1.7.5),但无法在Linux上加载 .
问题:为什么这样在linux上表现如此?有没有一种标准方法来在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"
]
}
Error on Ubuntu 14.04
wwwroot / app / people / 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:找不到模块'./people/People' . wwwroot / app / routes.config.ts(4,30):错误TS2307:找不到模块'./people/PersonDetail' .
正如您在github上的源代码中看到的那样,Person.ts包含位于wwwroot \ app \ core \ Person.ts中的类人员
请帮我解决这个问题 . 提前致谢 .
1 回答
我发现了这个问题 .
将所有文件夹和文件名保持为小写并在导入中复制相同的名称 . 它编译成功 .