Command tsc -w -p server
watch the server
directory compile TypeScript into dist/server
folder (dist/server/app.js
is the main Node script).
Command nodemon -w dist/server dist/server/app.js
watches dist/server
folder and reloads dist/server/app.js
when something changes.
The problem: if I run both commands in parallel, tsc
will take some times but nodemon
starts too soon, when dist/server/app.js
doesn't exist yet.
concurrently \"tsc -w -p server\" \"nodemon -w dist/server dist/server/app.js\"
On the other hand, if I run the commands sequentially I lost nodemon
output (that is, the server output) because tsc
will watch for changes and "steal" the console ouput:
tsc -w -p server\ && nodemon -w dist/server dist/server/app.js
I've tested both these strategies with nodemon and npm-run-all, a popular alternative.
Related questions (accepted answer doesn't solve the problem):