-
-
Notifications
You must be signed in to change notification settings - Fork 20.1k
Description
❗ Description
When running Express v5.1.0, even simple or basic route setups crash with the following error:
TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError
This originates from path-to-regexp used internally by Express: it throws when encountering a wildcard or parameter syntax with no name
.
🔍 Root Cause
Express 5 introduced a stricter path parsing rule requiring that wildcards or * matchers must now have explicit parameter names:
Previously in Express v4, catch-all routes like:
app.all('*', (req, res) => res.send('Not Found'));
were allowed.
In Express v5, they must be written as:
app.all('/*splat', (req, res) => res.send('Not Found'));
or to include root (i.e. match / as well):
app.all('/{*splat}', (req, res) => res.send('Not Found'));
where splat is a valid JS identifier used as req.params.splat
This breaking change is documented in the Express v5 migration guide under “Path route matching syntax”
.
📦 Minimal Repro Steps
const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello World'));
// Catch-all route triggers error in Express v5:
app.all('*', (req, res) => res.status(404).send('Not Found'));
app.listen(3000, () => console.log('OK'));
Running this with Express v5.1.0 causes:
TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError
When downgraded to Express v4.18.x, the server runs normally—even with the same wildcard syntax.
🧾 Additional Context
Confirmed by community posts and Stack Overflow questions on Express v5 migration: unnamed wildcards now cause this error
.
A GitHub issue in Express also hints that this behavior stems from recent path-to-regexp changes in v5
.
✅ Expected Behaviour
Express should gracefully support app.all('*') (or similar wildcard routes) even in v5, or at minimum:
Provide a clearer error message telling the user about the missing parameter naming requirement.
Update the documentation or migration guide to highlight this breaking change prominently—especially since the error stack trace is obscure.
📌 Suggested Fixes
Update official docs to emphasize that wildcard routes must be named in Express v5.
Improve error messaging within path-to-regexp to clarify when unnamed wildcard syntax is used.
Provide a fallback or warning if the wildcard syntax lacks a name, to avoid cryptic crashes.
🙏 Thanks
Thank you for maintaining Express! Even subtle breaking changes like this, once properly documented and handled, make future upgrades much smoother for developers.