2013-08-17 53 views
0

我試圖在Windows上編譯我的trypescript的應用程序,與打字稿沒有編制

C:/nodejs/tsc.cmd --sourcemap app.ts --module 

,這是我的錯誤:

C:\nodejs\node_modules\typescript\bin\tsc.js:55708 
        type = type.toLowerCase(); 
           ^
TypeError: Cannot call method 'toLowerCase' of undefined 
    at Object.opts.option.set (C:\nodejs\node_modules\typescript\bin\tsc.js:55708:33) 
    at OptionsParser.parse (C:\nodejs\node_modules\typescript\bin\tsc.js:55258:36) 
    at BatchCompiler.parseOptions (C:\nodejs\node_modules\typescript\bin\tsc.js:55771:18) 
    at BatchCompiler.batchCompile (C:\nodejs\node_modules\typescript\bin\tsc.js:55328:22) 
    at Object.<anonymous> (C:\nodejs\node_modules\typescript\bin\tsc.js:56015:7) 
    at Module._compile (module.js:456:26) 
    at Object.Module._extensions..js (module.js:474:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Module.require (module.js:364:17) 

理想的情況下,它說,有一個問題與打字稿本身,但似乎不太可能。

我安裝打字稿通過npm instal typescript和我的版本是0.9.1,任何幫助將不勝感激。

這是我的打字稿的代碼,我試圖編譯:

///<reference path='node/node.d.ts' /> 
///<reference path='node/express.d.ts' /> 

import http = module("http") 
import path = module("path") 
import express = module("express") 
import index = module("./routes/index") 
import user = module("./routes/user") 

var app = express(); 

app.configure(function(){ 
    app.set('port', process.env.PORT || 3000); 
    app.set('views', __dirname + '/views'); 
    app.set('view engine', 'jade'); 
    app.use(express.favicon()); 
    app.use(express.logger('dev')); 
    app.use(express.bodyParser()); 
    app.use(express.methodOverride()); 
    app.use(app.router); 
    app.use(express.static(path.join(__dirname, 'public'))); 
}); 

app.configure('development', function(){ 
    app.use(express.errorHandler()); 
}); 

app.get('/', index.index); 
app.get('/users', user.list); 

http.createServer(app).listen(app.get('port'), function(){ 
    console.log("Express server listening on port " + app.get('port')); 
}); 

回答

1

指定模塊類型。由於其節點的js這將是「CommonJS的」:

C:/nodejs/tsc.cmd --sourcemap app.ts --module "commonjs" 

更新:要解決HTTP未找到編譯時錯誤這裏是一個快速的打字稿定義:

declare module "http"{ 
} 
+0

現在,它給了我的錯誤,說該文件「http」未找到。 –

+0

@GamesBrainiac這是一個不同的問題,但更新的答案:) – basarat

+0

假設其編譯時錯誤 – basarat