So I already have written an article on how to setup an application with nodejs, typescript and nodemon. You can read that here. And there is a watch flag now available in the LTS of node as well which you can use to keep running the local server automatically without having to save.
But if for any reason you don’t want to use the watch flag and also my previous method is not working for you I have found a new way.
This method will work same for typescript application as well just make sure to put .ts as the file extension and also if your main files is in different folder then provide the path to the file properly.
So first as usual we will setup a basic node app with
Then create an index.js file in the root or wherever you have its fine and make sure you have this package installed tsx.
Now lets setup a basic express application that listens to a port number.
And now you are ready to add this script as dev script or which ever you use to run your local server
Now run this
npm run dev
you now have a local server running which will auto reload if you change anything.