Reputation: 102
-controller
---user_controller.js
-router
---user
------user_router.js
I have a file structure as above in my Express Js project, but I am facing difficulties to require user_controller from user_router. The only way I can required that is by using this method :
const user_controller = require(process.mainModule.path + '/controller/user_controller')
But something tells me that this might not be the best practice to do so. Anyone hove any idea to do so?
Upvotes: 0
Views: 102
Reputation: 102
require('./../../controller/user_controller')
do solved the problem. Sorry for being silly, and Thanks.
Upvotes: 0
Reputation: 3131
Try this:
const user_controller = require('../controller/user_controller);
Upvotes: 1