TSC Watch, Nodemon and Concurrently
We continue to setup our project, so that any changes we make to the source code are automatically recompiled and servable from the NodeJS server.
When compiling using TSC, when can also set the watch flag so that any changes to the source code are automatically recompiled.
We can host using
The nodejs doesn't restart when there are changes to the compiled output, so we can install nodemon
Now host the server using
Note the use of the
npx before the
nodemon command above. Since nodemon was installed with the
--save-dev option, you cannot call it directly from the command line unless it is also installed globally. Leave off the
--save-dev option if you want to install it globally. Prefixing the
nodemon command with
npx, as I do above, allows you to bypass the need to install it globally.
Rather than typing these compile and nodemon commands all the time, we can create a single command to start both processes at the same time.
Add this line to the package.json scripts section
And start using
Since we are running the
concurrently libs from the new
dev script in the projects
package.json, it is unnecessary to also have
concurrently installed globally if you don't really want to.