I have often been asked how I can run my Typescript project without converting it to vanilla javascript.
For sure, this is not something new, and there are many engineers already doing this, but since there are still many that don’t know how to do it, I decided to write a concise post about it to put two simple steps together.
Step one:
Install npm package ts-node
npm i ts-node -g
Run the Typescript file:
ts-node src/server.ts
Step two:
While step one is good enough to run your project but you might want to restart your project if there is a change in any file. To do that, you have to install the nodemon package. nodemon works perfectly on the Typescript project if you already installed ts-node beforehand.
Install npm package nodemon
npm i nodemon
Run the Typescript file:
nodemon src/server.ts