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

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon