I have been working for the different kinds of Node JS application from the last 4 years. For every project I tried to improve the performance and code quality. From that, I found a very interesting way to restart the typescript application so fast.

Introduction

When you are working with Node JS with Typescript you notice a significant delay while restarting the application by using ts-node.

ts-nodeone of the best tool for NodeJS-Typescript development but when comes to typescript it doesn’t do the best job.

Typical Typescript NodeJS App

A typical nodejs-typescript

nodemon.json look like these

{
    "watch" : ["src"],
    "ext" : "ts",
    "exec": "ts-node ./src/app/server.ts"
}

It will work fine but restart speed is too slow.

Don’t trust the Server Start time here, it actually took more than 20 seconds to restart.

Trail 1

So I was playing with the nodemon options to make restart faster and found we map our executable with params, so I create this configuration for

nodemon.json

{
  "env": {
    "NODE_ENV": "development"
  },
  "execMap": {
    "ts": "node --require ts-node/register"
  },
  "ext": "js,json,ts",
  "ignore": [
    ".git",
    "node_modules/**/node_modules"
  ],
  "restartable": "rs",
  "watch": [
    "src/"
  ]
}

#typescript #nodejs #development #faster-backend #code #coding #programming #nodejs-developer

How to Restart the TypeScript NodeJS Application Fast
7.15 GEEK