0%

Node+ts初探

简单启动

正常用 js 文件启动是

> node src/index

改成 ts 后

> ts-node src/index.ts

使用 nodemon

> nodemon --watch 'src/**' --exec ts-node

使用 alias

使用 alias 后 ts 识别不出来,需要用到 tsconfig-paths 和 tscpaths

> nodemon --watch 'src/**' --exec ts-node -r tsconfig-paths/register src/index.ts --files

tsc 编译时

> tsc && tscpaths -p tsconfig.json -s ./src -o ./dist