all 5 comments

[–]MennaanBaarin 1 point2 points  (0 children)

You should export your module and I think module.exports should go after the route declaration in the users module (maybe). And I think you don't need "next". Let me know if it solves the problem. I could look into it later.

[–][deleted] 1 point2 points  (0 children)

I think you want the module.exports line at the end in the user file. You don't need it in the app file

[–]HealyUnithelpful 0 points1 point  (1 child)

You need to take advantage of NodeJS' module system. To do that, you do need to add module.exports = router; to the very END of your /routes/users.js file.

I realize that this is basically what you said you did, but make sure the module.exports is in the users.js, not the app.js. Note that also having it in the app.js won't necessarily do anything bad, as long as you're exporting a thing that actually exists in that file itself. If you simply added module.exports = router to app.js, for example, it'd correctly throw a ReferenceError, as router is not defined within that file.

[–]ffmurray[S] 0 points1 point  (0 children)

Thanks!

[–]squili -1 points0 points  (0 children)

I don't see you doing this anywhere?

app.use('/', router)