Vue + Vite HMR problem

Not sure if it is a Vue or Vite issue, but when I change HTML in template tag in a Vue + Vite project, I’m getting an error:

ReferenceError: can't access lexical declaration 'ComponentName' before initialization


[hmr] Failed to reload /src/views/ComponentName.vue. This could be due to syntax errors or importing non-existent modules. (see errors above)

This is true only for some components/views and only regards template, the script and style tags don’t cause the erorr to happen. I cannot find any regularity in this, like it only affects a random number of components.
What can be causing this?

1 Like

I am also facing same issue. Whenever save, the app crashes with above error.

This is exactly the same issue for me. I’m also using vue in combination with vite and the issue appears whenever i save a .vue file.