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

225
Vistas
how to get current file name in node js when use type ES

module p.js

import url from 'url';

export function _file(){
    return url.fileURLToPath(import.meta.url)
}

index.js

import {_file} from './p.js';

console.log(_file()); // returns p.js instead of index.js

i want the index.js file address to be returned.

i know can pass the import.meta.url in the index.js as a method parameter, but I want to know if there is another way or not ???

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

0

There is not.

The module knows its own filename.

It doesn't know the name of some file some arbitrary distance up the stack.

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