🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsAmazon Prime Big Deal Days: October 6 to October 7, 2026(15.09.2026 um 11:36 Uhr)
🪟 Windows TippsSpotify(15.09.2026 um 11:30 Uhr)
🪟 Windows TippsKB5129194 Windows 11 26H1 Out of Band Update - Deskmodder.de(14.09.2026 um 19:25 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsAmazon Prime Big Deal Days: October 6 to October 7, 2026(15.09.2026 um 11:36 Uhr)
🪟 Windows TippsSpotify(15.09.2026 um 11:30 Uhr)
🪟 Windows TippsKB5129194 Windows 11 26H1 Out of Band Update - Deskmodder.de(14.09.2026 um 19:25 Uhr)

🔧 Programmierung 🕛 vor 3 Monaten 4 Min Lesezeit
0

Complete Guide: Setting Up a Node.js + Express + TypeScript Project

↗ Quelle (dev.to)
🗣️ Stimme:

Introduction



When building modern backend applications, combining Node.js, Express.js, and TypeScript provides a powerful and scalable development experience. Node.js offers a fast runtime environment, Express.js simplifies API development, and TypeScript adds static typing that helps catch errors during development.



In this guide, we'll create a Node.js backend project from scratch using Express and TypeScript.



Prerequisites



Before starting, ensure you have installed:




  • Node.js

  • npm (comes with Node.js)

  • VS Code (optional but recommended)



Verify the installation:




CODE
node -v
npm -v







Step 1: Create a New Project



Create a new folder and navigate into it:



mkdir backend

cd backend



Initialize a Node.js project:




CODE
npm init -y







This command creates a package.json file that manages project dependencies and scripts.



Project structure:




CODE
backend/
└── package.json






Step 2: Install Required Dependencies



Install Production Dependencies



These packages are required when the application runs in production.




CODE
npm install express cors dotenv







Package Overview



Package Purpose

express Web framework for building APIs

cors Enables Cross-Origin Resource Sharing

dotenv Loads environment variables from .env files

Install Development Dependencies



These packages help during development.




CODE
npm install -D typescript ts-node nodemon @types/node @types/express @types/cors






Package Overview



Package Purpose

typescript TypeScript compiler

ts-node Executes TypeScript directly

nodemon Automatically restarts the server

@types/node Node.js type definitions

@types/express Express type definitions

@types/cors CORS type definitions



Step 3: Initialize TypeScript



Generate the TypeScript configuration file:




CODE
npx tsc --init







This creates:




CODE
tsconfig.json







Step 4: Configure TypeScript



Replace the generated configuration with:




CODE
{
"compilerOptions": {
"target": "ES2022",
"module": "CommonJS",
"rootDir": "./src",
"outDir": "./dist",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src"],
"exclude": ["node_modules"]
}






Important Settings

Option Description

target JavaScript version to compile into

rootDir Source code location

outDir Compiled output location

strict Enables strict type checking

esModuleInterop Supports CommonJS imports



Step 5: Create Project Structure



A clean folder structure improves maintainability and scalability.



Create the following directories:




CODE
mkdir src
mkdir src/config
mkdir src/controllers
mkdir src/middlewares
mkdir src/routes
mkdir src/services
mkdir src/utils







Resulting structure:




CODE
backend/

├── src/
│ ├── config/
│ ├── controllers/
│ ├── middlewares/
│ ├── routes/
│ ├── services/
│ ├── utils/
│ ├── app.ts
│ └── server.ts

├── package.json
├── tsconfig.json
└── .env






Step 6: Create the Express Application



Create src/app.ts.




CODE
import express from "express";
import cors from "cors";

const app = express();

app.use(cors());
app.use(express.json());

app.get("/", (_, res) => {
res.json({
success: true,
message: "Server Running"
});
});

export default app;






What Happens Here?




  • Creates an Express application.

  • Enables CORS.

  • Parses JSON request bodies.

  • Adds a test route.



Step 7: Create the Server Entry Point



Create src/server.ts.




CODE
import dotenv from "dotenv";
import app from "./app";

dotenv.config();

const PORT = process.env.PORT || 5000;

app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});






Responsibilities of server.ts




  • Loads environment variables.

  • Starts the Express server.

  • Defines the application port.

  • Step 8: Create Environment Variables



Create a .env file:




CODE
PORT=5000







Using environment variables helps keep configuration separate from code.



Step 9: Configure Git Ignore



Create .gitignore.




CODE
node_modules
dist
.env






This prevents unnecessary files from being committed to version control.



Step 10: Configure Nodemon



Nodemon automatically restarts the server whenever files change.



Create nodemon.json:




CODE
{
"watch": ["src"],
"ext": "ts",
"ignore": ["dist"],
"exec": "ts-node src/server.ts"
}






Configuration Explanation

Property Purpose

watch Monitors source files

ext Watches TypeScript files

ignore Ignores compiled files

exec Command to run the application



Step 11: Add Scripts



Update package.json.




CODE
{
"scripts": {
"dev": "nodemon",
"build": "tsc",
"start": "node dist/server.js"
}
}






Script Explanation



Script Purpose

npm run dev Starts development server

npm run build Compiles TypeScript

npm start Runs production build



Step 12: Run the Application



Start the development server:



npm run dev



Expected output:




CODE
Server running on port 5000







Step 13: Test the API



Open your browser or API testing tool and visit:




CODE
http://localhost:5000







Response:




CODE
{
"success": true,
"message": "Server Running"
}






The API is now working successfully.



Step 14: Build for Production



Compile the TypeScript code:



npm run build



Generated structure:




CODE
dist/
├── app.js
└── server.js






Run the production build:




CODE
npm start







Recommended Production Packages



For real-world applications, install additional middleware:



npm install helmet morgan express-rate-limit

npm install -D @types/morgan



Why Use Them?

Package Purpose

helmet Adds security headers

morgan Logs HTTP requests

express-rate-limit Protects against abuse and brute-force attacks



Recommended Scalable Folder Structure



As your project grows, consider organizing it like this:




CODE
src/
├── config/
├── controllers/
├── routes/
├── services/
├── repositories/
├── middlewares/
├── validators/
├── interfaces/
├── types/
├── utils/
├── app.ts
└── server.ts






This structure works well for REST APIs, authentication systems, AI applications, e-commerce platforms, and enterprise-level backend services.



Conclusion



By combining Node.js, Express.js, and TypeScript, you gain:




  • Better code quality through static typing

  • Improved developer experience

  • Easier debugging and maintenance

  • Scalable project architecture

  • Faster development workflow with Nodemon



Following the setup described in this guide provides a solid foundation for building modern backend applications, whether you're creating REST APIs, microservices, AI-powered platforms, or full-stack web applications.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
The Gemini desktop app is now available for Windows
1 Quelle
Burn Out, Or Fade Away
1 Quelle
Windows 11 KB5129195 is out after Microsoft confirms major issues with the September 2026 update, but it won’t fix AMD GPU errors
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Complete Guide: Setting Up a Node.js + Express + TypeScript Project

Thematisch verwandte Begriffe: Complete, Guide, Setting, Nodejs · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...