I think what you want is something like this (my current setup):
"scripts": {
"compile": "tsc && node app.js",
"dev": "./node_modules/nodemon/bin/nodemon.js -e ts --exec \"npm run compile\""
}
I created two scripts “compile” and “dev”. To start developing you simply run npm run dev
which starts nodemon and makes it watch .ts files (using the -e
flag). Then, every time a .ts file changes nodemon will exec
the compile task which basically compiles and runs the node app.
While using concurrently is a good option, my setup guarantees that tsc
‘s work is done before attempting to execute the resulting .js files.