Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda