【问题标题】:Typescript - "Cannot compile modules unless the '--module' flag is provided."打字稿-“除非提供'--module'标志,否则无法编译模块。”
【发布时间】:2015-09-20 23:35:30
【问题描述】:

在一个打字稿项目中(使用 tsc 1.6.2,sublime 3 和打字稿插件 0.1.8)我有这个打字稿文件:

/// <reference path="../../typings/estree/estree.d.ts" />

export interface NodeWorker {

   nodeTypeFilters: Array<string>;

   enterNode(node: ESTree.Node, parent?: ESTree.Node): void;
   leaveNode(node: ESTree.Node, parent?: ESTree.Node): void;
}

我也有这个 tsconfig.json:

{
   "compilerOptions": {
       "module": "commonjs",
       "noImplicitAny": true,
       "listFiles": true,
       "removeComments": true,
       "preserveConstEnums": true,
       "rootDir": "./src",
       "outDir": "../built/",
       "sourceMap": true,
   }
}

我还有其他几个使用导入和导出的 .ts 文件,但仅在带有 NodeWorker 的文件上出现错误:“除非提供了 '--module' 标志,否则无法编译模块。”在出口声明上。

我看不到问题。

【问题讨论】:

  • 您的问题解决了吗?一旦我开始添加模块,VSCode 也不会为我的基本教程项目编译。 Typescript 本身确实编译为 javascript。但我找不到在哪里添加这个“--module”标志。

标签: typescript


【解决方案1】:

天哪,这太傻了。逗号在

“源地图”:真,

当然是错的。

【讨论】:

  • 嗯,它对我有用,那么你可能有不同的问题。
  • 使用 VS Code 时,标志应该是“out”而不是“outDir”。这似乎没有记录在任何地方。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-21
  • 2016-03-03
  • 2016-05-14
  • 1970-01-01
  • 2013-08-27
  • 2019-12-30
相关资源
最近更新 更多