How to run TypeScript files from command line?

前端 未结 13 1469
死守一世寂寞
死守一世寂寞 2020-11-27 10:13

I\'m having a surprisingly hard time finding an answer to this. With plain Node.JS, you can run any js file with node path/to/file.js, with CoffeeScript it\'s <

13条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 10:25

    How do I do the same with Typescript

    You can leave tsc running in watch mode using tsc -w -p . and it will generate .js files for you in a live fashion, so you can run node foo.js like normal

    TS Node

    There is ts-node : https://github.com/TypeStrong/ts-node that will compile the code on the fly and run it through node

提交回复
热议问题