Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
Node.js. How to get a path to imported file

I'm writing a parser and i'm getting imports like ../modules/greeting.js, also i have an absolute path to file (from where i have done an import) - for instance C:\Desktop\Folder\src\scripts\main.js.

How to get path to file which i have imported? (in this case it should be src/modules/greeting.js). Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use this for the absolute path to the imported file:

path.resolve(path.dirname('C:\\Desktop\\Folder\\src\\scripts\\main.js'), '../modules/greeting.js')

Returns: "C:\Desktop\Folder\src\modules\greeting.js"
Check the API docs for more path utils: https://nodejs.org/api/path.html

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda