Express 5 cheatsheet
Express 5: Setup
4 common Express 5 tasks.
Hello world server
The smallest Express app. It listens on port 3000.
import express from "express";
const app = express();
app.get("/", (req, res) => {
res.send("Hello World!");
});
app.listen(3000, () => console.log("Listening on http://localhost:3000"));
Run with auto-restart
Restart the server when files change, using Node's built-in watcher.
node --watch server.js
Load environment variables
Read PORT and other settings from a .env file.
node --env-file=.env server.js