DEV Community

Husna Ramadan
Husna Ramadan

Posted on

6 3 1 1 1

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

Neon image

Serverless Postgres in 300ms (!)

10 free databases with autoscaling, scale-to-zero, and read replicas. Start building without infrastructure headaches. No credit card needed.

Try for Free β†’

Top comments (0)

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay