Node.js and TypeScript: How to Set Up Your Development Environment in 2024
Configure Development Environment For Node.js and TypeScript
Remember in the previous part we built our project but we needed to transpile our TypeScript code every time we update our code before running our project. This is because node.js doesn’t have a built-in mechanism for watching code changes.
Of course there are packages out there like nodemon
that can give us this feature. But nodemon
is also doesn’t understand TypeScript on it’s own. So, we need another way to achieve that in order to configure a stable environments to watch and run our project.
If you just came here, make sure you check the previous parts to get an overview of what we are using in this tutorial, we have created express api server using node.js and TypeScript. Check it from here
First, let’s create our node start script, which will start our project from the build
directory. Therefore, we are going to add the following attribute and value under scripts
object in our package.json
file:
"scripts": {
"build": "npx tsc -p .",
"start": "node .",
...
},
To test that out, apply any change to your application and then run the build
then start
command and confirm that the…