Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
Require JS Module in Node JS without using DOTS in my file path

I'm using a lot of files of .JS in my project that are spread in multiple folders and whenever I need to require on of them , I'm ending up with some ugly require that looks like

const Employee = require('../../../abstracts/classes/Employee');

Or if I'm using another require that's located in the different folder in the path tree , it can be as follows:

const Client = require('../../abstracts/classes/Client');

Is there a way to save all the .. (dots) headache and use the father folder as a starting point?

Let's assume that my tree is as follows:

FatherFolder 
-main.js 
-abstracts/classes // here we have "Client.js" & "Employee.js"
-folder1/folder2/folder3/file1.js
-folder1/folder2/file2.js

And I want to require Employee.js and Client.js in file1 and file2 without using dots.

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!