Express.js is a fast, unopinionated, and minimalist web framework for Node.js, providing a robust set of features for building web and mobile applications. The current stable major version is 5.2.1, with the 4.x branch (currently 4.22.1) also actively maintained for security and critical fixes. Releases are frequent, often addressing security vulnerabilities or updating internal dependencies. Express differentiates itself through its flexible middleware-based architecture, allowing developers to build APIs and web servers with significant control and without being locked into a rigid structure, contrasting with more opinionated frameworks. It is widely adopted and serves as a foundational component for many other Node.js frameworks, emphasizing simplicity and modularity.
npm install expressVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic Express v5 server with JSON body parsing, custom logging middleware, defined routes, and comprehensive error handling, showcasing typical setup for a web API.
Upgrade your Node.js runtime environment to version 18 or higher before upgrading to Express v5.
Immediately upgrade to Express 5.2.1 or 4.22.1 to revert the query parser behavior to its stable state. Avoid using versions 5.2.0 and 4.22.0.
Replace `res.redirect('back')` with explicit URLs or manage redirect paths more directly within your application logic.Ensure all asynchronous route handlers and middleware either use `try...catch` blocks to pass errors to `next(err)`, or use an `express-promise-router` or similar utility to automatically catch unhandled promise rejections.
Upgrade to Express 5.0.1 or 4.21.1 (or newer patch versions) to ensure you have the fix for CVE-2024-47764.
Do not use Express 5.2.0 or 4.22.0. Ensure you are on 5.2.1, 4.22.1, or a later stable release to avoid the unintended query parser change.
Run `npm install express` or `yarn add express` in your project directory. If using a monorepo, check workspace configuration.
Verify that the function or module you are passing to `app.use()` is correctly imported and exported, and that it is indeed a function. For example, ensure you are not doing `app.use(myMiddleware.middlewareName)` when `middlewareName` is `undefined`.
Ensure you have `const express = require('express');` (CommonJS) or `import express from 'express';` (ESM) at the top of your file where you intend to use `express`.Always ensure that only one response is sent per request. Use `return` after sending a response (e.g., `return res.send('Done');`) to prevent further execution that might inadvertently send another response. Review asynchronous code paths to prevent multiple `res.send()` or `next()` calls.