使用ts-node和vscode直接运行typescript

学习测试ts代码的时候为了方便 不使用tsc去编译,用ts-node直接调用ts文件联调ts代码


首先全局安装ts-node

npm install -g ts-node

注意一定是全局安装,否则在调试过程中会报错。
然后新建一个ts文件(demo.ts)

enum Color {Red = 1, Green, Blue}
let c: Color = Color.Green;
console.log(c)

最后在终端进入到该文件夹目录下,运行文件即可。

ts-node .\demo.ts

猜你喜欢

转载自blog.csdn.net/qq_35517283/article/details/131959726