TypeScript 编译错误 TS5037:除非提供“--module”标志,否则无法编译外部模块

2024-05-10

无法编译任何 TS+node.js 项目(包括示例中列出的项目)http://typescript.codeplex.com/sourcecontrol/latest#samples/imageboard/README.txt http://typescript.codeplex.com/sourcecontrol/latest#samples/imageboard/README.txt

总是出现以下错误:

错误 TS5037:除非提供“--module”标志,否则无法编译外部模块。

编译器版本:0.9.1.0

例如,该项目仅包含单个文件 app.ts:


///<reference path="./node_definitions/node.d.ts" /

import http = require("http")

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, 'localhost');
console.log('Server running at http://localhost:1337/');


也只是补充一下。

我正在使用 Visual Studio 2013,运行构建时遇到同样的错误来修复它。我转到项目的属性,然后转到“TypeScript Build”部分,其中可以选择选择模块系统,我选择了 AMD,但没有。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TypeScript 编译错误 TS5037:除非提供“--module”标志,否则无法编译外部模块 的相关文章

随机推荐