How to set up a Node.js project with a clean folder structure (TypeScript)
A step-by-step guide to creating a Node API server
6 min readJan 29, 2023
In this step-by-step tutorial, we will learn how to initialize a node project. Node is not a programming language but a run-time environment that enables JavaScript to run on server-side. However, JavaScript is a weakly typed language, and often in large code-base it is difficult to read, understand codes/logics and find bugs.
TypeScript is a super-set of JavaScript which is a strongly typed language. A TypeScript project is written and later transpiles into JavaScript which then can be run by node run-time environment.
Prerequisites
- A basic knowledge of JavaScript/TypeScript
- Postman or similar tool to test API
- A basic understanding of MongoDB or any other database
- VS Code or any code editor of your choice
- Node.js installed on your operating system (Install Node.js)
Step 1: Create a folder and initialize with npm
Open up your terminal, create a folder and move into that:
mkdir node-tutorial
cd node-tutorial