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.
According to the StackShare community, ts-node has a broader approval, being mentioned in 538 company stacks & 274 developers stacks; compared to ts-node-dev, which is listed in 24 company stacks and 7 developer stacks.
No you shouldn't use it in production, even though it will cache the compiled files it'll be slower to start and consume more memory because it keeps around an instance of the compiler and files in memory.
In this case, if we make any changes to the project then we will have to restart the server by killing it using CTRL+C and then typing the same command again.
As of v1. 19.0, nodemon has inbuilt support for TypeScript files with help from ts-node that requires no manual configuration. By default, nodemon uses the node CLI as an execution program for running JavaScript files; for TypeScript files, nodemon uses ts-node as the execution program instead.
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.
--exit-child
worked for me too.
Example in package.json
"scripts": {
"start": "ts-node-dev --respawn --transpile-only --exit-child --watch src src/index.ts"
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With