In this article, I will explain the simple step by step process of creating a new server with Express in TypeScript.

This example requires basic knowledge of  Node.js,  npm and  Visual Studio Code.

Setup project

Before we get started, we need to create a directory for our project. For this we enter mkdir typescript-express and confirm with Enter.

We change into the directory with cd typescript-express and set up the project.

First, we create a Node.js package with the command npm init -y.

After that we can install the modules for our project. Therefore we install Express with npm i express.

Since we are working in TypeScript, we also need TypeScript and Typings for Express. We do that with the command npm i -D typescript @types/express.

Last but not least, let’s create the configuration for TypeScript. For this we use the command npx tsc --init. The TypeScript compiler will create a predefined file with all possible settings.

Here all commands one after the other…

mkdir typescript-express
cd typescript-express

npm init -y
npm i -D typescript @types/express
npm i express
npx tsc --init

For more information on setting up a project for TypeScript, I can only refer to one of my previous article Simple setup for your next TypeScript project.

#debugging #javascript #nodejs #typescript #servers

Setup Express in TypeScript with Node.js
1.35 GEEK