只有'amd'和'系统'模块与--out一起支持

OCD*_*Dev 41 typescript phaser-framework visual-studio-code

在VSCode中构建typescript时,我收到以下错误:

错误TS6082:在--out旁边只支持'amd'和'system'模块.

我的设置如下:

tsconfig.json

{
    "compilerOptions": {
        "target": "ES5",
        "module": "commonjs",
        "out": "current/game.js",
        "removeComments": true,
        "sourceMap": false
    }
}
Run Code Online (Sandbox Code Playgroud)

.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"
}
Run Code Online (Sandbox Code Playgroud)

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

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

C S*_*ver 35

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

  • 只需删除"模块":"commonjs",就可以完成这项工作.谢谢! (12认同)
  • 同样,您也可以更改为"模块":"无". (2认同)
  • 我收到“错误 TS6131:无法使用选项“outFile”编译模块,除非“--module”标志是“amd”或“system”。” (2认同)