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

210
Visualizações
JavaScript get caller original line number from minified code

I try to implement a small custom logger in our JavaScript project that contains multiple source files. It is minified, but during the development with a full source map. (Webpack: devtool: "inline-source-map")

If I log an error object to the console then I can see the real line numbers. However, if I want to process it and use Error.stack then I get the line numbers from the minified code that is almost useless.

This is my example code:

const err = new Error();
const stack = err.stack;

console.log('Error: ', err);
console.log('Error: ', stack);

And the output:

Error:  Error
    at log (background.ts:18)
    at background.ts:29
    at eventService.ts:170
    at util.ts:124
    ...

Error:  Error
    at log (chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:735:17)
    at chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:746:1
    at chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:889:3
    at chrome-extension://hkikkdnnkfiomhblbgonboibnjgkjocp/background.js:891:12
    ...

Is there a way to get the real source in case of a minified code? Can I get the first error output in a processable manner?

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