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

487
Visualizações
Why do I get "Uncaught ReferenceError: Cannot access X before initialization" only in HMR in Vite?

I'm using Vite + React.

I run my project using npm run dev and everything is fine. Project runs and I can use it inside the browser.

Then I open some files, change them and save.

As soon as I save I see this ugly error:

Uncaught ReferenceError: Cannot access 'X' before initialization

And that X can be a lot of things.

Some points here:

  1. I've seen many questions related to this in which developers use a variable and then declare it. That's not my case. Their code won't work the first time. Mine works the first time.
  2. Let's say I have 5 lists and 5 forms inside my app. I change List2.jsx and I see that List1.jsx caused this error. WTF? Nobody has changed List1.jsx, why should it now cause an error?
  3. When I save a .jsx file, I expect to see that file's updated version in my browser's Network tab. But what I see is that a lot of files are being reloaded again. Why? I just changed one file, one character, and why should I see all of these files being reloaded again?
  4. How can I debug this?
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