nodemon compile typescript and execute js file 1

nodemon compile typescript and execute js file

/* 
	this is an example to compile ts file and then run app.js 
	you can modify according to your requirement
	below is example of simple npm script compile and execute ts file
*/
"start": "nodemon --watch *.ts --exec 'tsc *.ts && node app.js'"

Here is what the above code is Doing:
1. nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
2. –watch *.ts tells nodemon to watch all files with the .ts extension for changes.
3. –exec ‘tsc *.ts && node app.js’ tells nodemon to execute the TypeScript compiler (tsc) on all files (*.ts) and then execute the resulting JavaScript file (app.js) using node.

Similar Posts