【转存】使用tsc -w监视编译和使用ts-node直接在node下运行typescript

一、使用tsc -w进行随时热更新watch

  • 通过tsc -w 命令,使得tsc监视文件变化从而实现实时编译 如图 但是要记得写tsconfig.json tsconfig:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "build/buildFile",
"target": "ES2020",
"outDir": "dist",
"module": "ES6",
"diagnostics": true
},
"include": [
"src/**/*"
]
}

二、使用ts-node直接运行ts的node项目

首先全局安装ts-node ```npm install -g ts-node``` 直接进行ts-node 启动文件名