This lesson walks through building a complete, working Express server from an empty file, then testing it in the browser and with curl. By the end you will have a real server responding to multiple routes.
Writing Your First Server
A minimal Express server needs three things: an app created from express(), at least one route, and a call to app.listen() with a port number. Everything else builds on top of that foundation.
Save the following as server.js inside a project where you have already run npm install express.
Forgetting express.json() and then reading req.body as undefined on POST requests.
Using the same port as another running process, causing an EADDRINUSE error.
Not checking the terminal for the "Server running" log to confirm the server actually started.
Testing POST/PUT/DELETE routes by pasting the URL into a browser address bar, which only sends GET.
Key Takeaways
A minimal server needs express(), at least one route, and app.listen().
res.send() is for simple text/HTML, res.json() is for structured API data.
curl lets you test any HTTP method, not just GET, from the command line.
A catch-all app.use() at the end of your routes is a simple way to handle unmatched paths.
Pro Tip
Log the full URL, not just the port, from your listen() callback (e.g. http://localhost:${PORT}), so you can click it directly in most terminals instead of retyping it.
You have a working Express server responding to real requests. Next, compare Express with raw Node.js in the Express.js vs Node.js lesson to see exactly what Express saves you from writing.