Search code examples
node.jstypescriptnpmcommandpackage.json

How do I execute typescript watch and running server at the same time?


I was developing my project in nodejs. I found if I need to code and test api, I will run two console, one is to execute typescript watch, another is to execute server.

I think it's so troublesome. I find other developers on github have written scripts in package.json. It's easy to call any commands. It attracts how to write the scripts and simply my development workflow.

In short, the comand of typescript watch is tsc -w and the comand of running server is node app.js. My idea is merge the commands as tsc -w & node app.js but I can't work the two commands at the same time. How do I do? Thanks.


Solution

  • My idea is merge the commands as tsc -w & node app.js but I can't work the two commands at the same time. How do I do

    You have a few options. Simplest is to use ts-node-dev : https://github.com/whitecolor/ts-node-dev