[英]TypeScript: tsc.exe --execute: Error cannot find module
我有以下目錄設置:
/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)
有任何想法嗎?
您的代碼很好。 -e
標志已從tsc中刪除,部分原因是它在這種情況下不能很好地發揮作用。 在編譯器過程的上下文中執行任意JS並不是一個好主意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.