javascript - 如何通过打字稿模块制作节点模块
问题描述
如何将 typescript 模块构建为 javascript 模块
这是我的 tsconfigFile
{
"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
};
解决方案
由于您的配置似乎具有生成节点模块所需的设置,我认为您只需要运行tsc
命令,它就会生成 JS 代码并将其存储在./dist
目录中。
推荐阅读
- mysql - MySQL Workbench 无法在 Mac 上打开
- javascript - 转换类类型并调用静态属性
- python - 如何使用 Python 读取 Oracle 存储过程的内容
- python - 具有多个组的熊猫中的长到宽格式
- python - 在矩阵中管理和子串多个字符串(Python & Numpy)
- python - 如果任何值满足掩码要求,则为整个数组返回 True/False
- qt - QtCreator 说:x“未安装 SDK 工具”
- java - 如何通过 nextPageToken 实现分页?
- scala - 为 HList 类型构建类型类实例列表
- excel - 如何以循环方式包含一个值以进行迭代计算?