Express.js is the most popular web framework for Node.js, powering everything from tiny hobby APIs to production systems at major companies. It is deliberately minimal: it gives you routing, middleware, and helpers for requests and responses, then stays out of your way. In this first lesson you will learn what Express is, why developers choose it, and how to set up a clean project ready for the rest of this series.
Node.js ships with a built-in http module, but using it directly means manually parsing URLs, checking request methods with if statements, and hand-writing response headers. Express wraps that module with a small, expressive API. Instead of one giant request handler, you declare routes such as app.get('/users') and Express matches incoming requests to them automatically.
Express is often described as unopinionated. It does not force a folder structure, a database, or a template engine on you. That flexibility is why it sits at the heart of the classic MEAN and MERN stacks and why frameworks like NestJS are built on top of it.
You need Node.js version 18 or newer and npm, which is bundled with Node. Verify both from your terminal:
node --version
npm --versionIf either command fails, download the LTS installer from nodejs.org. Basic JavaScript knowledge (functions, objects, callbacks, and arrow functions) is assumed throughout this series.
Create a folder and initialize a package.json, which records your dependencies and scripts:
mkdir express-tutorial
cd express-tutorial
npm init -y
npm install expressThe npm install command downloads Express into node_modules and adds it to the dependencies section of package.json. As of Express 5, the framework requires Node 18+, and features like async error forwarding work out of the box.
Create index.js with the smallest possible app to prove the setup works:
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Express is installed correctly!');
});
app.listen(3000, () => console.log('Listening on http://localhost:3000'));Run node index.js, open http://localhost:3000 in a browser, and you should see the confirmation message. We will dissect every line of this file in the next lesson.
Restarting the server after every edit gets old quickly. Install nodemon as a development dependency and add npm scripts:
npm install --save-dev nodemonThen in package.json add:
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
}Now npm run dev restarts the server automatically whenever you save a file, which keeps your feedback loop tight while learning.
Next up: Your First Express Server, where we walk through the request/response cycle line by line and send text, JSON, and status codes.