Use ts-node to run typescript NodeJS project

ts-node saves time to build ts project to js and use node xxx.js to run, it compiles the ts files on the fly but unfortunately, WebStorm does not have an option to debug it

Easiest solution I have found

Edit the default config, add this in node params

--inspect --require ts-node/register

As suggested by Vadorequest in the comment, the latest version does not require --inspect option. So if you find the above param does not work, try his solution. Thanks for the suggestion Vadorequest!

--require ts-node/register

The result looks like this, now you can set breakpoints and start debugging your code!

Easy enough?

Leave a Reply

Your email address will not be published. Required fields are marked *