How to set up a Node server with TypeScript in 2024
A quick tutorial on how to set up a Node project in 2024. Includes TypeScript, live reload, and environment variable support.
I’ve had to look up how to create a new Node server enough times that I’m writing it down to make it easier for me to find in the future. This is a quick and dirty post without much context or explanation. Feel free to ask me for details if something I said isn’t clear.
This is the fastest way I know of to get a Node server running with TypeScript as of 2024. If you know a better way, please do let me know!
Set up the project
Next, open package.json
and add the following:
Add environment variables, if needed
Create .env
and put any secrets inside:
Create the main Node app file
Create src/index.ts
and put something inside:
Start the Node server and test live reload
Start the server with npm run dev
and you’ll see the following output:
Make a change to src/index.ts
or .env
and the server will automatically restart and show your changes in the console.
And that’s it — now you’ve got a Node app with TypeScript running with live reloading and environment variables, using as few dependencies as possible, modernized for building apps in 2024.
Happy building!