How to run TypeScript files from command line?

前端 未结 13 1472
死守一世寂寞
死守一世寂寞 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:40

    For environments such as Webstorm where the node command cannot be changed to ts-node or npx:

    1. npm install ts-node typescript (Install dependencies)
    2. node --require ts-node/register src/foo.ts (Add --require ts-node/register to "Node parameters")

提交回复
热议问题