DEV Community

Husna Ramadan
Husna Ramadan

Posted on

Hot Reload Typescript with ts-node-dev

Hi, folks!

To learn essenstial Typescript i should see the result of my code. And, cause i don't want to running command repeatdly, i use this single tool ts-node-dev by Alex.

This tool is faster ⚡⚡ than any other, like nodemon.

First, install your ts-node-dev

sudo npm i ts-node-dev -g

-g or --global flag for install it globally, if you're going to want it you should add sudo command for user invoke access root.

You have got it 😤

In your package.json on section below "script": add hot reload command, like this:



"scripts": {
    ...
    "dev": "ts-node-dev --respawn src/index.ts"
}


Enter fullscreen mode Exit fullscreen mode

On the dev section you just set your main file scr/index.ts and --respawn flag itself for restarts the node target.

And, look at my result of ts-node-dev 😎😎

https://imgur.com/ytYpBYu.png

Oh, I forgot. This solution from here

https://stackoverflow.com/questions/37979489/how-to-watch-and-reload-ts-node-when-typescript-files-change

Top comments (0)