node.jstypescriptnodemontscts-node

ts-node-dev not restarting when changes made


Here are my files :

package.json :

"scripts": {
  "generate-interfaces": "ts-node src/cli/generate-interfaces.ts",
  "dist": "npm run generate-interfaces && rm -rf dist && tsc && cp -r static/ dist/ && cp -r resource/ dist/",
  "prestart": "npm run generate-interfaces",
  "start": "ts-node-dev --respawn --transpileOnly --no-notify ./src/index.ts",
  "start:inspect": "ts-node-dev --no-deps --inspect -- ./src/index.ts",
  "pretest": "npm run generate-interfaces",
  "test": "jest"
 }

tsconfig.json

{
"compilerOptions": {
"declaration": true,
"target": "es2017",
"module": "commonjs",
"esModuleInterop": true,
"outDir": "dist",
"sourceMap": true,
"skipLibCheck": true,
"typeRoots": ["node_modules/@types", "./typings", "node_modules/**/*.d.ts"],
"lib": ["esnext"]
},
"include": ["src/**/*.ts", "./typings/**/*.d.ts"],
"exclude": ["node_modules/**", "dist"]
}

When I do any changes, I get the little popup, but it doesn't actually restart the server not sure what I am doing wrong here.

Note: The first time I do changes after server restart manually it shows me a popup and something like this in the terminal [INFO] 22:07:09 Restarting: src/analytics-engine.ts has been modified after that no changes detection.


Solution

  • The issue is resolved now. I found out the problem using --debug that it was an error related to 'SIGTERM'. So I added a flag --exit-child in my npm start script.