【问题标题】:How to make node module by typescript module如何通过打字稿模块制作节点模块
【发布时间】:2021-10-16 11:24:37
【问题描述】:

如何将 typescript 模块构建为 javascript 模块

这是我的 tsconfig 文件

{
  "compilerOptions": {
    "target": "ES5",
    "module": "CommonJS",
    "declaration": true,
    "outDir": "./dist",
    "strict": true,
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}

我想构建这个代码 --------------

打字稿模块

import getData from './getData';


export default {
 getData 
};

节点模块

const getData = require("./getData")';

module.exports = {
  getData
};

【问题讨论】:

  • 我不明白你的问题,但要编译 TS,你需要命令 tsc。

标签: javascript node.js typescript node-modules module-build


【解决方案1】:

由于您的配置似乎具有生成节点模块所需的设置,我认为您只需要运行tsc 命令,它就会生成JS代码并将其存储在./dist目录中。

【讨论】:

    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 2014-07-07
    • 2017-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多