Course contentsShow
← TypeScript
Lesson 69 of 1,7962. Setup and ToolingFree lesson

nodemon with ts-node for Auto-Restart

Combine nodemon and ts-node to restart your Node server automatically on file changes.

nodemon with ts-node for Auto-Restart

What you'll learn: How to combine nodemon and ts-node so your TypeScript server automatically restarts whenever you save a file.


Why Combine nodemon and ts-node?

You already know that ts-node lets you run TypeScript directly without manually compiling, and that tsc --watch can recompile files automatically. But tsc --watch only recompiles—it doesn't restart your running application.

nodemon is a tool that watches your files and automatically restarts your Node.js process when changes are detected. When you pair it with ts-node, you get the best of both worlds: execute TypeScript directly and restart automatically on every save.

Think of it like having an assistant who not only translates your notes (ts-node) but also taps you on the shoulder to start fresh every time you update them (nodemon).


Setting It Up

First, install nodemon as a development dependency:

npm install --save-dev nodemon

Then run your TypeScript file using nodemon with ts-node:

npx nodemon --exec ts-node src/server.ts

Now every time you save src/server.ts (or any file it imports), nodemon detects the change and reruns ts-node src/server.ts.


Configuration Tip

You can create a nodemon.json file to customize behavior, but for most beginner projects, the command above is enough to get productive immediately.


Key Takeaway: Combining nodemon with ts-node gives you automatic server restarts on file changes, creating a smooth development workflow without manual compilation or restarting.