typescript 仅支持 'amd' 和 'system' 模块与 --out 一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35963346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:00:10  来源:igfitidea点击:

Only 'amd' and 'system' modules are supported alongside --out

typescriptvisual-studio-codephaser-framework

提问by OCDev

When building typescript in VSCode, I get the following error:

在 VSCode 中构建打字稿时,出现以下错误:

error TS6082: Only 'amd' and 'system' modules are supported alongside --out.

错误 TS6082:与 --out 一起仅支持“amd”和“system”模块。

My settings are as follows:

我的设置如下:

tsconfig.json

配置文件

{
    "compilerOptions": {
        "target": "ES5",
        "module": "commonjs",
        "out": "current/game.js",
        "removeComments": true,
        "sourceMap": false
    }
}

.vscode/tasks.json:

.vscode/tasks.json:

{
    "version": "0.1.0",

    // The command is tsc. Assumes that tsc has been installed using npm install -g typescript
    "command": "tsc",

    // The command is a shell script
    "isShellCommand": true,

    // Show the output window only if unrecognized errors occur.
    "showOutput": "silent",

    // args is the HelloWorld program to compile.
    "args": [],

    // use the standard tsc problem matcher to find compile problems
    // in the output.
    "problemMatcher": "$tsc"
}

Despite the error, the game.js file does get created and runs properly.

尽管有错误,game.js 文件确实被创建并正常运行。

Anyone have any thoughts about what might cause this error?

任何人对可能导致此错误的原因有任何想法?

采纳答案by C Snover

It means what it says. You can't use --out/--outFileto bundle modules together for Node.js/CommonJS, since there is no bundle format for CommonJS. Simply don't use that option for CommonJS and corresponding JS files will be emitted for each input TS module file.

这意味着它所说的。您不能使用--out/--outFile将 Node.js/CommonJS 的模块捆绑在一起,因为 CommonJS 没有捆绑格式。简单地不要对 CommonJS 使用该选项,并且将为每个输入 TS 模块文件发出相应的 JS 文件。