My TypeScript + NodeJS + Express setup for maximum productivity


Hello! This guide is dedicated to both new and experienced developers who would like to setup their workflow in developing backend APIs in NodeJS using TypeScript and Express (or anything you would like).

"scrips": {
"buildAndWatch": "tsc -w -p tsconfig.json",
"startAndWatch": "nodemon ./dist/index.js"

What you will need


  1. Project setup | Quick initialization and dependencies installation
  2. Workflow and scripts| Automate work by letting the scripts do it for you

Project Setup

I’m going to create a new project from scratch, but you can apply the same dependencies if they are not installed to your existing project.
Since I’m using VS Code I’ll just create a new folder and open VS Code there.

Project initialization

Open the terminal and navigate to your project directory
Pro Tip: You can use CTRL + ` (or Command + ` on Mac) in VS Code to toggle the terminal or go to View -> Terminal

npm init -y
Output of running the npm init -y command

Installing dependencies

With the terminal still open, it’s time to install our dependencies.
I usually install Typescript and Nodemon as global packages since I’m using them on most of the projects.

npm install -g typescript nodemon 
tsc --init
npm install --save expressnpm install --save-dev @types/express @types/node

Workflow and scripts

First, let’s create a server with a simple route that serves some data.
Create index.ts:

import express, { Application, Request, Response } from 'express' const app: Application = express();app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// Other configurations like using helmet, setting up routesapp.get('/api/demo', (request: Request, response: Response) =>
response.json({ fancyJson: 'Goes here' });
app.listen(() => console.log('Server started at http://localhost:3000/ ...')
tsc -p tsconfig.json
node ./dist/index.js
"scrips": {
"buildAndRun": "tsc -p tsconfig.json && node ./dist/index.js"
"scrips": {
"buildAndWatch": "tsc -w -p tsconfig.json",
"startAndWatch": "nodemon ./dist/index.js"
npm run buildAndWatch
npm run startAndWatch

I’m a software and game developer passionate about clean code, architecture, cars and efficiency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store