Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

490
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!