- 创建项目:
npm init -y
- 创建tsconfig:
tsc --init
- 配置:
package.json
{
...
"type": "module",
"scripts": {
"start": "ts-node-esm index.ts",
...
}
- 配置
tsconfig.json
{
"compilerOptions": {
...
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "NodeNext",
...
}
}