小编use*_*582的帖子

如何将Node.js的TypeScript代码编译为一个文件?

我想在使用Node.js时将TypeScript编译为一个文件.

我试过像这样配置"tsconfig.json":

"compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "noImplicitAny": false,
    "sourceMap": false,
    "outFile": "./app/index.js",
    "pretty": true,
    "types": [
      "node"
    ]
  }",
Run Code Online (Sandbox Code Playgroud)

...但是当我尝试使用module" set to"commonjs"时,我得到错误:

error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
Run Code Online (Sandbox Code Playgroud)

如果我将其更改为"module": "system",则在运行该文件时出现此错误node:

ReferenceError: System is not defined
Run Code Online (Sandbox Code Playgroud)

如果我module改为"amd",我在运行文件时遇到此错误node:

ReferenceError: define is not defined
Run Code Online (Sandbox Code Playgroud)

node.js typescript typescript2.0

14
推荐指数
2
解决办法
4546
查看次数

标签 统计

node.js ×1

typescript ×1

typescript2.0 ×1