-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vite HMR not working . Changing code does not reflect on page until restart vite server #16284
Comments
Seems like not all HMR affected. |
Are you using Chrome? In that case can you give it a try on FIrefox? |
@swennemans I had this issue in Brave and it does work in Firefox. In Brave, I don't get any errors and don't get the Update: I've restarted the browser for a different reason and now this went away and I can see the refreshed page with no issues. |
Same problem, when i change .ts, it dosn't update in browser. I'm on macOS i7 using vite 5.2.0 and node 18. |
from: node 20-21 - windows Exactly the doc's setup:
=> Please make the HMR backend work normally as 5.0 ! |
I also have issues with HMR, it appears that HMR wont work if Vite is not installed at the top level of your diretory, I made a sample app in vite-svlte/vite-project, and on initial install HMR worked, closed VS Code and cd into vite-project and HMR no longer works. On Windows 11. |
I was getting this same issue after creating a project using the |
Consistent with the test results of @VQH-cmd, the last working version was [email protected], while v5.1.0 and the latest version v5.3.3 are both damaged. I noticed an interesting phenomenon, HMR works when I test it in Firefox, but once I visit it once with Safari, HMR will fails in both Safari and Firefox, it freezes at the last modification before the Safari visit. That said, it appears that Safari's request caused the HMR to break and freeze. |
Downgrading to 5.0.12 didn't solve it for me. --EDIT-- |
Stumbling upon this issue no matter what version of Vite I'm using. Tried 5.0.9, tried 5.3.3, tried 4.5.3 ... while developing an application based on Vue. Sometimes I can even break the code severely with neither Vite showing me any severe build error in console nor browser showing me the common warning box overlay ... yes, it happens when testing application in Chrome. But it happens when testing it in Firefox as well. When entering another line like console.log( "foo" ); that change isn't picked up at all. I doubt it is even recognized by Vite itself. UPDATE: Vite seems to pick up the change as it keeps counting up in the console output when writing something like 00:39:44 [vite] hmr update /src/views/input/FightView.vue, /src/views/input/PreparationView.vue (x5) |
I have the same issue with a monorepo achitectutre. I tried both Chrome and Firefox even Safari I even forced HMR by using |
I am having the same issue. I use named exports only, classes and typescript, in a react project using the react-typescript-swc template. Whenever I change something, the hot reload is alerted in the console, the browser is refreshed, but the actual code changes are not picked up, thus making hmr essentially useless. |
Vite + React HMR is fully functional in my case. My problem was that I had responsive Tailwind widths and Chrome would not display adjusted elements at the biggest breakpoint 2xl, e.g. 2xl:w-3/5 would not set the element width to 60% despite that 2xl stands for 1536px and I am running Chrome on the screen with 1920x1080. It turns out that there is an Ubuntu desktop bar and Firefox and Chrome treat it differently, Firefox ignores it while Chrome subtracts bar's width from the browser viewport resolution thus not reaching those 1536px, I think. In any case, my problem was not caching or Vite, though it is useful to know about ctrl+shift+r to reload the page without caching and F12->Network->Disable Cache in Chrome. |
I am also getting the same issue HMR is not working, even the changes are not being populated after the manual restart and i have tried incogito , removed the cache, and re install the packages the problem still persists. |
I also had this HMR issue. In my case, it seemed to be caused by the fact that I was using WSL for development. I ran npm run dev in WSL, but when I opened the browser on my Windows computer, the code changes were not reflected. If anyone is using WSL and doesn’t experience this issue, please share your solution. Currently, my approach is to develop in the Windows environment, where everything works properly. import { defineConfig } from "vite"; // https://vitejs.dev/config/ |
So I also ran into the same issue, I have recently upgraded a Ruby on Rails app from 5.1 to 7.2 and I have integrated Vite into my project. My issue is related to safari, as I have tested Firefox and Chrome and both seem to work without any issue. If I empty the cache then it works but that is not a good option for me. I have disabled Cache in the network tab as well and that didn't help me either. So looking for ideas, I prefer working with Safari so if anyone has any workaround that will do as well. BTW I am on the latest beta of MacOS Sequoia 15.1. |
Not sure this is relevant to OP, but if you have access to the underlying
This fixed all HMR related issues for me. |
I was able to resolve my issues by adding export default defineConfig({
plugins: [react()],
server: {
watch: {
usePolling: true
}
}
}) Why exactly? No idea, found it on the internet 🤷 Edit: well, documentation explains it pretty clearly:
|
I experienced this on macOS Sequoia 15.2 and @alan-mroczek's solution worked. edit: This could be related to my code being on a removable volume, in my case. Though I have not confirmed this yet. |
Not sure if this will help anyone else, but in my case I was working with TanStack router and had the code below. My index route was hot reloading just fine, though, so I started to look at what the differences were. I found that removing the
|
Describe the bug
I setup a basic react+ts template and expect HMR to work. But It does not.
When I change some values inside App.tsx / main.tsx or any components, it does not updates in browser.
I'm on macOS m1 using vite 5.2.6 and node 18.
I did setup chokidar simple test to check if events get trigged. It works!
Reproduction
http://google.com
Steps to reproduce
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: