How to import a module that is in a different folder in Node.js?

Cordial greetings, I hope you are well.

I would like some guidance on how I can import a module that is in another folder.

Here is an image:

However when importing the module it generates me error:

Error: Cannot find module '../controllers/index.js'
Require stack:

I would be very grateful for your guidance.

25 thoughts on “How to import a module that is in a different folder in Node.js?”

  1. you’re really a good webmaster. The web site loading velocity is amazing.

    It sort of feels that you are doing any distinctive trick.
    Furthermore, The contents are masterwork. you’ve done a fantastic process
    in this matter!

  2. First off I would like to say fantastic blog!
    I had a quick question which I’d like to ask if you don’t mind.
    I was interested to find out how you center yourself and clear your head prior to writing.

    I have had a tough time clearing my thoughts in getting my thoughts out.
    I truly do enjoy writing but it just seems like the first 10 to 15 minutes tend to
    be wasted just trying to figure out how to begin. Any suggestions or hints?

    Feel free to surf to my site – Keto Redux Review

  3. Hi, I do believe this is an excellent web site.
    I stumbledupon it 😉 I’m going to return once again since i have bookmarked it.

    Money and freedom is the greatest way to change,
    may you be rich and continue to help other people.

    Take a look at my homepage – Viag Rx


Leave a Comment