express icon indicating copy to clipboard operation
express copied to clipboard

[DEPLOY-ERROR] - TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError - Firebase Functions Project - Updated to Version 5 - Firebase Deploy Failed

Open aoneahsan opened this issue 1 year ago • 8 comments

[DEPLOY-ERROR] - TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError - Firebase Functions Project - Updated to Version 5 - Firebase Deploy Failed

Screenshot 2024-09-10 at 3 37 19 PM

kingsman97:functions ahsan$ nmr deploy:specific

deploy:specific npm run pre-deploy && firebase deploy --only functions:get_generic_in_app_notifications,functions:get_user_role_specific_in_app_notifications,functions:get_user_specific_in_app_notifications

pre-deploy npm run unlink-packages

unlink-packages yarn unlink zaions-tool-kit && yarn unlink zaions-express-tool-kit && yarn install --force

yarn unlink v1.22.22 success Removed linked package "zaions-tool-kit". info You will need to run yarn install --force to re-install the package that was linked. ✨ Done in 0.04s. yarn unlink v1.22.22 success Removed linked package "zaions-express-tool-kit". info You will need to run yarn install --force to re-install the package that was linked. ✨ Done in 0.05s. yarn install v1.22.22 [1/5] 🔍 Validating package.json... [2/5] 🔍 Resolving packages... [3/5] 🚚 Fetching packages... [4/5] 🔗 Linking dependencies... warning " > [email protected]" has unmet peer dependency "jest@>=28.0.0". [5/5] 🔨 Rebuilding all packages... success Saved lockfile. ✨ Done in 4.55s.

=== Deploying to 'aoneahsan-learn-p2'...

i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run build

build npm run cleanOutputDir && tsc && tsc-alias

cleanOutputDir rimraf ./lib

✔ functions: Finished running predeploy script. i functions: preparing codebase default for deployment i functions: ensuring required API cloudfunctions.googleapis.com is enabled... i functions: ensuring required API cloudbuild.googleapis.com is enabled... i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled... ✔ functions: required API cloudfunctions.googleapis.com is enabled ✔ functions: required API cloudbuild.googleapis.com is enabled ✔ artifactregistry: required API artifactregistry.googleapis.com is enabled i functions: Loading and analyzing source code for codebase default to determine what to deploy Serving at port 8526

TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError at name (/Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:85:19) at lexer (/Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:103:27) at lexer.next () at Iter.peek (/Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:119:38) at Iter.tryConsume (/Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:125:28) at Iter.text (/Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:141:30) at consume (/Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:166:29) at parse (/Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:197:20) at /Volumes/Personal/01-code-work/firebase-projects/01-zaions/100-ahsan-learn-p1-v1/functions/node_modules/router/node_modules/path-to-regexp/dist/index.js:308:74 at Array.map ()

Error: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error

aoneahsan avatar Sep 10 '24 10:09 aoneahsan

reverted back to "v4.20.0" and it worked.

issue only occurrs when i update express to "v5.0.0"

aoneahsan avatar Sep 10 '24 10:09 aoneahsan

project depedencies

Screenshot 2024-09-10 at 3 38 19 PM

aoneahsan avatar Sep 10 '24 10:09 aoneahsan

yes i know this is "next" major release, and current stable version on NPM is "4.20.0", just want to bring this to attention as well, so once on NPM we can the stable version to "5.." it will be fixed before that, thanks :)

aoneahsan avatar Sep 10 '24 10:09 aoneahsan

Express 5.0.0 uses router 2.0.0, which uses path-to-regexp 8.0.0 and it brings some breaking changes to path handling.

The error that you got is caused by using : or * in one of your paths, which is not followed by parameter name. In Express 5 the wildcard * means something different than in 4.x. In 4.x it would match anything, but in 5.0 it behaves like : and is a named parameter.

You should check your paths, especially ones with :, *, ? and + to make sure that they are compatible with the new changes.

You can find more details in changelogs and the link shown in the error message:

  • https://github.com/pillarjs/router/blob/master/HISTORY.md#200--2024-09-09
  • https://github.com/pillarjs/path-to-regexp/releases/tag/v8.0.0
  • https://github.com/pillarjs/path-to-regexp?tab=readme-ov-file#missing-parameter-name

krzysdz avatar Sep 10 '24 11:09 krzysdz

Express 5.0.0 uses router 2.0.0, which uses path-to-regexp 8.0.0 and it brings some breaking changes to path handling.

The error that you got is caused by using : or * in one of your paths, which is not followed by parameter name. In Express 5 the wildcard * means something different than in 4.x. In 4.x it would match anything, but in 5.0 it behaves like : and is a named parameter.

You should check your paths, especially ones with :, *, ? and + to make sure that they are compatible with the new changes.

You can find more details in changelogs and the link shown in the error message:

* https://github.com/pillarjs/router/blob/master/HISTORY.md#200--2024-09-09

* https://github.com/pillarjs/path-to-regexp/releases/tag/v8.0.0

* https://github.com/pillarjs/path-to-regexp?tab=readme-ov-file#missing-parameter-name

I think that Express 5.x documentation may have an error: image

If you try this you'll trigger the TypeError: Unexpected ( at 0, expected END: https://git.new/pathToRegexpError error. Would be worth fixing this to prevent confusion.

furnivall avatar Sep 10 '24 12:09 furnivall

EDIT: Migration guide should be ready for some time now: https://expressjs.com/en/guide/migrating-5.html#path-syntax

@furnivall Yes, the documentation has not been updated yet. '(.*)' was recommended since 5.0.0-beta.1, but won't work any more in 5.0.0. Now if you want to use your own regular expression, it has to be passed directly:

app.get(/(.*)/, (req, res, next) => {
    console.log(req.path, req.params); // req.params will be { '0': '/the/path' }
    next();
});

If you want to match all paths including root, you can combine named parameters and optional segments:

app.get('/{*splat}', (req, res, next) => {
    console.log(req.path, req.params); // req.params will be { 'splat': '/the/path' }
    next();
});

krzysdz avatar Sep 10 '24 12:09 krzysdz

Yep, we had to synchronize releases for security reasons, but we were unable to get the docs all updated. Please open PRs with this where you can, we will need all the help we can get.

wesleytodd avatar Sep 10 '24 13:09 wesleytodd

🚀 Bounty Alert!

💰 A bounty of $30.00 has been created by omarsoufiane on BountyHub.

🔗 Claim this bounty by submitting a pull request that solves the issue!

Good luck, and happy coding! 💻

bountyhub-bot avatar Sep 13 '24 15:09 bountyhub-bot

hey @aoneahsan I'd like to resolve this bug, can you please what particularly do I need to do here ?

An525ish avatar Oct 23 '24 20:10 An525ish

hey @aoneahsan I'd like to resolve this bug, can you please what particularly do I need to do here ?

@An525ish

@krzysdz here "https://github.com/expressjs/express/issues/5936#issuecomment-2340677058" explained the solution well, please follow it.

let me know if you need any further assistance.

JFR, now

expressApp.use("*", handler())

is not going to work, instead we need to use "own regular expression" like expressApp.use("/(.*)/", handler())

aoneahsan avatar Oct 23 '24 20:10 aoneahsan

hey @aoneahsan I'd like to resolve this bug, can you please what particularly do I need to do here ?

@An525ish

@krzysdz here "#5936 (comment)" explained the solution well, please follow it.

let me know if you need any further assistance.

JFR, now

expressApp.use("*", handler())

is not going to work, instead we need to use "own regular expression" like expressApp.use("/(.*)/", handler())

little mistake

instead of

expressApp.use("/(.*)/", handler())

Use

expressApp.use(/(.*)/, handler()); // without double quotes

ZulluBalti avatar Apr 16 '25 06:04 ZulluBalti

"breaking changes" (sigh) Really thought I was done hearing phrases like that when I left corporate development. If only a phrase like "backward compatibility" had been invented when this software was written.

Glad I found this thread while chasing down this idiotic error. I appreciate those who provided answers and insight. I spent way too much investigative time trying to figure it out before finding this thread.

chornbe avatar May 15 '25 02:05 chornbe

oi alguem pode me ajudar com o erro:PS C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin> node server.js [[email protected]] injecting env (5) from .env C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:73 throw new TypeError(Missing parameter name at ${i}: ${DEBUG_URL}); ^

TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError at name (C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:73:19) at lexer (C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:91:27) at lexer.next () at Iter.peek (C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:106:38)
at Iter.tryConsume (C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:112:28) at Iter.text (C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:128:30)
at consume (C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:152:29)
at parse (C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:183:20) at C:\Users\vhsilva\OneDrive - ccee.org.br\Documentos\catalogo-geral (1)\catalogo-geral\central-admin\node_modules\path-to-regexp\dist\index.js:294:74 at Array.map ()

Node.js v23.9.0

victoraraujo4828 avatar Jun 27 '25 05:06 victoraraujo4828

这个错误真的很折磨人 ,对我这种小白来说,我还是选择使用 "express": "^4.18.2"这个版本。

Vawet avatar Jul 24 '25 10:07 Vawet

Please take a look at the migration guide. I know some features aren't available the same way they were in version 4, but for the vast majority of cases, the available functionality should be enough to solve them. https://expressjs.com/en/guide/migrating-5.html#path-syntax

bjohansebas avatar Jul 24 '25 15:07 bjohansebas

Off-topic, but .... funny enough, LLMs aren't up to speed with this one yet. They still provide * syntax, even when asked for 5.0. I wonder if these "breaking changes" will become a problem for LLMs. Anyway. :)

monarchwadia avatar Aug 17 '25 00:08 monarchwadia

I wrote systems and business software a few decades. The term “breaking changes” meant incident reports, EBFs, and usually people got fired. Now I guess it’s just par for the course.

Software development in general is in really sad shape. :(

On Aug 16, 2025, at 8:16 PM, Monarch Wadia @.***> wrote:

monarchwadia left a comment (expressjs/express#5936) https://github.com/expressjs/express/issues/5936#issuecomment-3193991662 Off-topic, but .... funny enough, LLMs aren't up to speed with this one yet. They still provide * syntax, even when asked for 5.0. I wonder if these "breaking changes" will become a problem for LLMs. Anyway. :)

— Reply to this email directly, view it on GitHub https://github.com/expressjs/express/issues/5936#issuecomment-3193991662, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZHS6PVLLFVCDH74IYSGXL3N7CXBAVCNFSM6AAAAABN6OKT22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJTHE4TCNRWGI. You are receiving this because you commented.

chornbe avatar Aug 17 '25 00:08 chornbe