【发布时间】:2016-01-06 08:28:56
【问题描述】:
我使用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 上加载。
问题:
- 为什么在 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"
]
}
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 的类 person
请帮我解决这个问题。提前致谢。
【问题讨论】:
-
你确定在 Ubuntu 上使用相同版本的 typescript (1.7.5) 吗?我看到你的
package.json有"typescript": "^1.6.2" -
是的,我在全球范围内安装了 tsc。我在更正 package.json 中的版本后尝试运行,仍然得到相同的错误。
标签: ubuntu-14.04 angular linux-mint typescript1.7