TypeError: Invalid token at 1: https://git.new/pathToRegexpError

I just deployed the project on Render, and as instructed, I had to change the backend path from localhost to http(s)://example.onrender.com, but it keeps giving an error related to pathToRegexp.

Missing parameter name at 1: https://git.new/pathToRegexpError

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>path-to-regexp/dist/index.js:85
throw new TypeError(Missing parameter name at ${i}: ${DEBUG_URL});
^
TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError
at name (path-to-regexp/dist/index.js:85:19)
at lexer (path-to-regexp/dist/index.js:103:27)
at lexer.next (<anonymous>)
at Iter.peek (path-to-regexp/dist/index.js:119:38)
at Iter.tryConsume (path-to-regexp/dist/index.js:125:28)
at Iter.text (path-to-regexp/dist/index.js:141:30)
at consume (path-to-regexp/dist/index.js:166:29)
at parse (path-to-regexp/dist/index.js:197:20)
at path-to-regexp/dist/index.js:308:74
at Array.map (<anonymous>)
Node.js v20.15.1
[nodemon] app crashed - waiting for file changes before starting...
</code>
<code>path-to-regexp/dist/index.js:85 throw new TypeError(Missing parameter name at ${i}: ${DEBUG_URL}); ^ TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError at name (path-to-regexp/dist/index.js:85:19) at lexer (path-to-regexp/dist/index.js:103:27) at lexer.next (<anonymous>) at Iter.peek (path-to-regexp/dist/index.js:119:38) at Iter.tryConsume (path-to-regexp/dist/index.js:125:28) at Iter.text (path-to-regexp/dist/index.js:141:30) at consume (path-to-regexp/dist/index.js:166:29) at parse (path-to-regexp/dist/index.js:197:20) at path-to-regexp/dist/index.js:308:74 at Array.map (<anonymous>) Node.js v20.15.1 [nodemon] app crashed - waiting for file changes before starting... </code>
path-to-regexp/dist/index.js:85
            throw new TypeError(Missing parameter name at ${i}: ${DEBUG_URL});
                  ^

TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError
    at name (path-to-regexp/dist/index.js:85:19)
    at lexer (path-to-regexp/dist/index.js:103:27)
    at lexer.next (<anonymous>)
    at Iter.peek (path-to-regexp/dist/index.js:119:38)     
    at Iter.tryConsume (path-to-regexp/dist/index.js:125:28)
    at Iter.text (path-to-regexp/dist/index.js:141:30)     
    at consume (path-to-regexp/dist/index.js:166:29)       
    at parse (path-to-regexp/dist/index.js:197:20)
    at path-to-regexp/dist/index.js:308:74
    at Array.map (<anonymous>)

Node.js v20.15.1
[nodemon] app crashed - waiting for file changes before starting...

Running npm start gave this error.

I tried using ChatGPT for help, but it’s still not working. I also tried updating my node_modules and checking the routes, but it’s still not working.

1

I had the same issue and found a way to fix it.

  • Delete your current package.json file
  • Run npm install express@latest (this will install express^4.20.0) and overwrite the current express installation
  • Run npm audit to see the audit logs of your application (you may see some vulnerabilities and a suggestion to upgrade express to 5.0.0, ignore them).

I noticed that I had this problem after installing a new package and I had some vulnerability issues so I ran npm audit fix --force and this upgraded my express installation to 5.0.0 among other things. This 5.0.0 version is a beta version so it keeps causing this issue you’re having. You have to downgrade it to 4.20.0 which is the latest stable release

If you’re working with an Express application, reinstalling Express worked for me. You most likely installed the Express 5.0 beta version by running npm audit fix --force to fix vulnerabilities

  • Delete package-lock.json
  • Reinstall Express package by running npm install express

0

The TypeError: Missing parameter name at ${i} error was reported in issue expressjs/express #5936. It was concluded that the documentation has not been updated since the last release. They suggested the following as a temporary workaround until the update:

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

Source: expressjs/express #5936, comment from krzysdz

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>app.get(/(.*)/, (req, res, next) => {
console.log(req.path, req.params); // req.params will be { '0': '/the/path' }
next();
});
</code>
<code>app.get(/(.*)/, (req, res, next) => { console.log(req.path, req.params); // req.params will be { '0': '/the/path' } next(); }); </code>
app.get(/(.*)/, (req, res, next) => {
    console.log(req.path, req.params); // req.params will be { '0': '/the/path' }
    next();
});

Source: expressjs/express #5936, comment from krzysdz

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật