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

275
Vistas
NodeJS: How to get a path a module was imported from

I have a module with some exported function that creates a file.

fs.appendFile(`${__dirname}/file_name`, 'aaaa', () => {});

When I import this module using a require syntax, when calling the function, the file is created in .node_modules/my_module/ (probably as expected). The question is how can I make it to create a file in the folder I'm calling this function.

I don't have an option to inject the path when calling the function, in the real app it's called by a third party reflection mechanism.

about 4 years ago · Juan Pablo Isaza
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