【问题标题】:TypeScript: tsc.exe --execute: Error cannot find moduleTypeScript:tsc.exe --execute:错误找不到模块
【发布时间】:2013-07-23 05:00:24
【问题描述】:

我有以下目录设置:

/app/ioc.ts
/tests/test.ts

我在测试目录中。 app/ioc.ts的内容不重要,但tests/test.ts的内容是:

import IOC = module('../app/ioc');
var container = new IOC.Container();

如果我这样编译:

tsc test.ts

然后像这样运行它:

node test

一切都好!该文件运行没有错误。然而!如果我这样运行:

tsc -e test.ts

我收到以下错误:

module.js:340
    throw err;
          ^
Error: Cannot find module '../app/ioc'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:/dropbox/work/sandbox/Prototyping/TypeScript/tests/test.js:1:73)
    at Module._compile (module.js:456:26)
    at Object.run (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56041:30)
    at BatchCompiler.run (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56563:29)
    at BatchCompiler.batchCompile (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56795:26)
    at Object.<anonymous> (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56908:7)

有什么想法吗?

【问题讨论】:

    标签: node.js typescript


    【解决方案1】:

    您的代码很好。 -e 标志正在从 tsc 中删除,部分原因是它不能很好地适应这种情况。在编译器进程的上下文中执行任意 JS 并不是一个好主意。

    【讨论】:

      猜你喜欢
      • 2018-12-30
      • 1970-01-01
      • 2016-12-20
      • 1970-01-01
      • 1970-01-01
      • 2021-01-20
      • 1970-01-01
      • 2023-04-03
      • 2017-01-21
      相关资源
      最近更新 更多