I ran across this error today, and was thoroughly confused. I also found the solution, so wanted to share in case others hit the same thing!
The error:
TypeError: Cannot read property 'match' of undefined
at /node_modules/next-routes/dist/index.js:102:27
at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/node_modules/express/lib/router/index.js:317:13)
at /node_modules/express/lib/router/index.js:284:7
at Function.process_params (/node_modules/express/lib/router/index.js:335:12)
at next (/node_modules/express/lib/router/index.js:275:10)
at expressInit (/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/node_modules/express/lib/router/index.js:317:13)
at /node_modules/express/lib/router/index.js:284:7
I ran across this error today, and was thoroughly confused. I also found the solution, so wanted to share in case others hit the same thing!
The error:
The cause
I had changed the example code:
server.js
Ie; I had introduced a destructruing
require
, which resulted in the above error.The fix
Stick with a non-destructured
require
like the docs show:server.js