仅支持 'amd' 和 'system' 模块与 --out 一起使用 [英] Only 'amd' and 'system' modules are supported alongside --out

查看:40
本文介绍了仅支持 'amd' 和 'system' 模块与 --out 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VSCode 中构建 typescript 时,出现以下错误:

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

错误 TS6082:仅支持 'amd' 和 'system' 模块--出.

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

我的设置如下:

tsconfig.json

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

.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"
}

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

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

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

Anyone have any thoughts about what might cause this error?

推荐答案

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

It means what it says. You can’t use --out/--outFile to 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.

这篇关于仅支持 'amd' 和 'system' 模块与 --out 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆