【问题标题】:Only 'amd' and 'system' modules are supported alongside --out仅支持“amd”和“system”模块以及 --out
【发布时间】:2016-06-28 01:31:12
【问题描述】:

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

错误 TS6082:仅支持“amd”和“system”模块 --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 文件确实已创建并正常运行。

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

【问题讨论】:

  • 我刚刚遇到了这个错误并执行了谷歌搜索以找到解决方案,我很高兴看到其他人提出了这个问题。瞧,是我问的!谢谢你自己!
  • 当你在 Google 上搜索并找到你自己的 StackOverflow 答案时,圆圈就完成了????

标签: typescript visual-studio-code phaser-framework


【解决方案1】:

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

【讨论】:

  • 只需删除“模块”:“commonjs”,就可以完成这项工作。谢谢!
  • 同样你也可以改成"module":"none"。
  • VS 2017 抱怨选择“none”
  • 不去掉commonjs,应该使用其他的,比如amd,如果要捆绑的话。
  • 我收到error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'.
猜你喜欢
  • 2017-06-10
  • 2019-12-24
  • 2017-02-08
  • 2017-07-08
  • 2015-12-16
  • 1970-01-01
  • 2012-11-20
  • 2013-03-24
  • 2014-05-23
相关资源
最近更新 更多