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

224
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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