nodejs – using typescript with nodemon

Create a new directory and run the command below in it

Next install nodemon with

Add a script tag to your package.json to execute the nodemon command. This works because npm looks under node_modules/.bin for an executable. The package.json looks then like this

Create a new file index.js, this is the default file nodemon looks for when started without any parameters. index.js contains only:

Now start the nodemon executable

Now if you change the index.js file nodemon will restart and execute nodejs with the new index.js file.

Now we want to make use of TypeScript. Install the typescript compiler locally together with the ts-node binary with

Also add a new script to your package.json called tsc. The complete contents of the package.json file is shown below:

Now you will need a tsconfig.json for the typescript compiler. Create a tsconfig.json file with default settings with:

Now to start monitoring your ts files start the ‘start’ node script with


Leave a Reply

Your email address will not be published. Required fields are marked *