Skip to content

TypeError: Missing parameter name at 2: https://git.new/pathToRegexpError #6428

Closed

Description

@eru123

Environment information

Version: v5.1.0

Platform: Linux 6.8.0-1021-aws 23~22.04.1-Ubuntu SMP Tue Dec 10 16:50:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Node.js version: v16.20.2

Any other relevant information: N/A

What steps will reproduce the bug?

# Installing the latest express cause the issue
npm install express

then throws error

TypeError: Missing parameter name at 2: https://git.new/pathToRegexpError
    at name (/var/www/<project>/node_modules/path-to-regexp/dist/index.js:73:19)
    at lexer (/var/www/<project>/node_modules/path-to-regexp/dist/index.js:91:27)
    at lexer.next (<anonymous>)
    at Iter.peek (/var/www/<project>/node_modules/path-to-regexp/dist/index.js:106:38)
    at Iter.tryConsume (/var/www/<project>/node_modules/path-to-regexp/dist/index.js:112:28)
    at Iter.text (/var/www/<project>/node_modules/path-to-regexp/dist/index.js:128:30)
    at consume (/var/www/<project>/node_modules/path-to-regexp/dist/index.js:152:29)
    at parse (/var/www/<project>/node_modules/path-to-regexp/dist/index.js:183:20)
    at /var/www/<project>/node_modules/path-to-regexp/dist/index.js:294:74
    at Array.map (<anonymous>)
/var/www/<project>/node_modules/path-to-regexp/dist/index.js:73
            throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);

Temporary Fix

Downgrade to 4.21.2

npm install express@4.21.2

Activity

  1. added theissue type on Apr 1, 2025
  2. MrShadow50 commented on Apr 1, 2025

    @MrShadow50

    yes I got also same issue

  3. slagiewka commented on Apr 1, 2025

    @slagiewka
    Contributor

    I you go to the DEBUG_URL: https://git.new/pathToRegexpError

    You will see in the README:

    Missing parameter name
    Parameter names must be provided after : or *, and they must be a valid JavaScript identifier. If you want an parameter name that isn't a JavaScript identifier, such as starting with a number, you can wrap the name in quotes like :"my-name".
    

    I would assume that your route contains *. Please confer the migration guide before opening issues: https://expressjs.com/en/guide/migrating-5.html#path-syntax

    PS: Node.js version: v16.20.2 please note that express v5 requires node v18. Also note that node v16 has ben EoL since September 11th, 2023.

  4. wesleytodd commented on Apr 1, 2025

    @wesleytodd
    Member

    Yep, as @slagiewka says, please read our migration guide. v5 is a breaking upgrade, and you will need to make some changes to the path syntax you use. If you still think this is a bug after addressing the changes from the guide, please post the route definitions you have and we can take a look. I will leave this open only because I anticipate more folks asking the same question, but will remove the bug label as this is likely not a bug.

  5. removed theissue type on Apr 1, 2025
  6. NetWin commented on Apr 1, 2025

    @NetWin

    I had this problem aswell and can confirm that this is "simply" a breaking change from the V5 update.
    As described in the changelogs here routes like app.use('/**', ...) are not supported anymore.

    This problem came up while updating express in an Angular SSR application for me. When setting up SSR, Angular generated exactly the example mentioned above for me. But changing it to app.use('/{*path}', ...) fixed the problem for me. 👍

    Screenshot from the migration section of the express homepage:

    Image

  7. eru123 commented on Apr 2, 2025

    @eru123
    Author

    Thanks @wesleytodd and @slagiewka, I confirmed that it is a breaking issue with the new version.

    As for our usecase we only have this one route, that accepts all requests and send in the index.html of our frontend build, and you guys are correct, this one is causing the issue.

    app.get('/*', function (req, res) {
      res.sendFile(path.join(__dirname, '../build', 'index.html'));
    });

    I opened this issue yesterday because we have to rollback our production and it cost us downtime and delay our app release thinking it's a fault on our recent changes.

    Funny enough, it's our mistake, we have this untouched code in our Dockerfile for ~5 years now and a package-lock.json is not generated until deployment as we do the expressjs installation on docker build, basically it's always installing the latest version 😭.

    RUN npm install express

    With this, I conclude that this issue is resolved, you guys can close this anytime if no one wants to add more. I just hope no major impact to production servers out there because of silly mistakes like what we did.

  8. MrShadow50 commented on Apr 2, 2025

    @MrShadow50

    @eru123 same with me I am using express to serve my react build and last 3-year code was working but because I also face same issue after this critical issue, I realize does not matter how much contributor are working on any lib it can have major issue after whole application.

  9. wesleytodd commented on Apr 2, 2025

    @wesleytodd
    Member

    This is true of all libraries, you have benefited these past years from the stability (and stagnation 😉) of the project. If you are doing something like npm install express in your build you need to specify a version you rely on. Change that to npm install express@5 now and then when we release v6 which will also include breaking changes you will avoid this pain.

    I will still keep this open for now, because it avoids more duplicate issues, but glad to hear your issue is resolved @eru123!

  10. pinned this issue on Apr 2, 2025
  11. wesleytodd commented on Apr 2, 2025

    @wesleytodd
    Member

    In fact, I just pinned this issue so that folks are more likely to see it than to open a new one.

  12. 17 remaining items

  13. detobel36 commented on May 4, 2025

    @detobel36

    For people who use Angular, the upgrade has been done here: angular/angular-cli#29989

  14. rajneeshshukla1608 commented on May 31, 2025

    @rajneeshshukla1608

    Go back to previous version this will fix the error

  15. Kaike-R commented on Jun 18, 2025

    @Kaike-R

    Hey everyone,

    I had the same issue, and I worked around it using a regex:
    app.get(/.*/, (req, res) => { res.sendFile(path.resolve(__dirname, "frontend", "index.html")); });

    Not sure if this will solve your problem too, but it worked for me!

  16. denniac commented on Jun 18, 2025

    @denniac

    I had the same issue upgrading to Express 5 with Angular 20 and node lts/jod (v22.16.0); I had to roll back to express@4.21.2.

  17. bjohansebas commented on Jun 21, 2025

    @bjohansebas
    Member

    hey @Kaike-R @Deni8dev Changing the route to /{*splat}, doesn't it work?

  18. Kaike-R commented on Jun 26, 2025

    @Kaike-R

    @bjohansebas I tested it here, and it worked for me too! I haven’t gone deep into the discussion, but I noticed there are three workarounds for this problem. Among these—{/{splat}},{ /./}, and {'/*\w'} —which one is the most recommended?

  19. tagobuyhelp commented on Jul 23, 2025

    @tagobuyhelp

    I have been trying to fix this problem for three to four hours and after seeing this post, I got the temporary fix and got the job done for now.

  20. RijanDhakal commented on Jul 31, 2025

    @RijanDhakal

    Hey everyone,

    I had the same issue, and I worked around it using a regex: app.get(/.*/, (req, res) => { res.sendFile(path.resolve(__dirname, "frontend", "index.html")); });

    Not sure if this will solve your problem too, but it worked for me!

    man thats freaking helpful , i was seacrhing for this from hours i added '/.*/' it added undeined like my fetchURl + undeined + route , so i just set the fecthing of data without fetch url. I was stuck to this for hours man

  21. ikwijaya commented on Aug 12, 2025

    @ikwijaya

    still issue for me today
    express 5.1.0

    Image

    the error in console
    Image

  22. RijanDhakal commented on Aug 15, 2025

    @RijanDhakal
  23. locked and limited conversation to collaborators on Aug 23, 2025
  24. converted this issue into a discussion #6723 on Aug 23, 2025
  25. unpinned this issue on Aug 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions