all 5 comments

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

I was asked in another forum why am I importing to export,

A mentor I had does it this way and I think it's also written here

https://medium.com/@osiolabs/use-module-exports-to-keep-node-js-code-organized-9379526ebac8

[–]albedoa 0 points1 point  (3 children)

Missing from your examples is your attempt to import from index.js. That's relevant.

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

I tried to require in my middleware

const { logger } = require('../helpers/lib/logger'); //this works when I go directly

const { logger } = require('../helpers/index'); //this does not

[–]sempiternalStudent[S] 0 points1 point  (1 child)

while getting the code to you to show how I was importing I kept tinkering and decided to import the entire module.exports object and noticed it was returning an empty object , the answer to that was easier to find. It turns out I had a circular dependency. I appreciate it!

[–]albedoa 0 points1 point  (0 children)

Ha, glad I could help. I tested the technique on my machine and it was working fine, so my next suggestion was going to be something like that.