How to Set up a TypeScript + NodeJs Server (2024)
With new releases and tools, setting up a node server has become super simple, and until NodeJs ships with typescript built-in, adding typescript will be an essential need.
I will show you the SIMPLEST setup you can have to kick off your next node project confidently. For simplicity, you can customize it with the things you need to complete your project.
Project Directory Setup
Let’s start by setting up your project directory
mkdir YOUR_PROJECT_NAME
cd YOUR_PROJECT_NAME
git init # start your git project
npm init -y # initialize npm with defaults
mkdir src # create the source directory for all the code
One thing we need to do is ensure our project is of type module
in the package.json
.
{
"name": "YOUR_PROJECT_NAME",
"version": "1.0.0",
"description": "",
"type": "module",
"scripts": {},
"keywords": [],
"author": "",
"license": "MIT"
}
I recommend going for module and ESM in general and leaving behind the commonjs
…