Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics Parameters, Query Strings, and Modularizing Routes Modular Routes

I have problem when declaring router: debug('dispatching %s %s', req.method, req.url);

This is my detail error. I don't understand: " node app.js /home/xuanhai/SelfTeach/flashcards/node_modules/express/lib/router/index.js:139 debug('dispatching %s %s', req.method, req.url); ^

TypeError: Cannot read property 'method' of undefined at Function.handle (/home/xuanhai/SelfTeach/flashcards/node_modules/express/lib/router/index.js:139:33) at router (/home/xuanhai/SelfTeach/flashcards/node_modules/express/lib/router/index.js:47:12) at Object.<anonymous> (/home/xuanhai/SelfTeach/flashcards/routes/index.js:31:18) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19)"

Abraham Juliot
Abraham Juliot
47,353 Points

do you have a link to your workspace. You can share a snap shot link via treehouse workspaces or I recommend pushing your project to a github repo and sharing the link.

1 Answer

nico dev
nico dev
20,364 Points

Hi Xuan Hai,

May I ask? How did you declare router?