我正在努力让这项工作,但我似乎找不到任何解决方案,所以.try 编译此单文件应用程序时:
import http = require('http')
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
使用命令"tsc app.ts--module'commonjs'"我得到以下错误(不使用--module标志会给我一个额外的错误,告诉我需要它来编译外部模块):
error TS2071: Unable to resolve external module '"http"'.
error TS2072: Module cannot be aliased to a non-module type.