You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WSL 2: ReactJS not reloading after saved. [Solved] #10253
I recently installed WSL 2 but when I create an app using create-react-app and use npm start the app was’t reloaded when I edited and saved some file
Describe the solution you'd like
I want to use Hot Reloading on my Projects located in Windows file system.
WSL2 changed the file sharing protocol, from using their own custom developed protocol using the 9P protocol, which does not support file changes event for Create React App.
Describe alternatives you've considered
To FIX this issue : You can put your code on the Linux file system (example : in your user’s home directory ), and access these files through the WSL share, \wsl$\DISTRO_NAME from Windows.
@PrajjwalDatir "VM" is just the example the CRA team used for their documentation there. Really, Chokidar is a file watcher for Node, so it handles the "proxy" part of your development setup (remote container, WSL, VM, etc.).
How do I know? Just last week I set up a project with VS Code's Remote Containers, which had exactly the same problem you described here. With Chokidar, my changes are actually noticed by VS Code.
To quickly test it out, just change your start script in the package.json to { ... "start": "CHOKIDAR_USEPOLLING=true react-scripts start" ... }
Reacted by Prajj, Chloe Sun, CesareoAguirre, Sabatiny, ankusharya, Workata, johnnycakesgino, fathnasrudin, Rebecca Bristow, Joshua Enrico and 25 more
Reacted by Izak T
Reacted by Prajj, Chloe Sun, Workata, johnnycakesgino, Joshua Enrico, Piotr C., Izak T, Lucas Castro and Mathieu
Reacted by Izak T, Abdul Rehman, Rogério Gouvêa and Mathieu
Reacted by Prajj, vk1204133, G. Leon Plata Camacho, Marco Thomazini, Chinmay Dali, Anmoldeep Singh Arora, CesareoAguirre, shaoye, William Brode, mvp and 74 more
Reacted by Rahil Arora, RayanShah, xshameem, nicole-hoon, Drabzee, Vishwa Kumar, Kawan, Shubham Arora, Prajwal Murthy, Code Terra and 4 more
Reacted by Junior Botelho, Sparsh Temani, Agustín Andrews, Izak T, Hariraj Venkatesan and Miguel Galvez
Reacted by redmaster90, Juan Felipe, Vaibhav Dhingra, Agustín Andrews, Laura Avinyó Esteban, Marcin Różewski, jopergy, Izak T, Thi Đặng, Sirgeeyou and 4 more
Reacted by Ihab Heb, Marco Thomazini, Chinmay Dali, mvp, Junior Botelho, Prajj, Joshua Enrico, Vaibhav Dhingra, Agustín Andrews, Izak T and 3 more
Reacted by thy-jumrylsolivio, Seffiani Hassan and Miguel Galvez
This didn't solve the issue for me. My situation remains same as described in the original issue description.
I have also tried the CHOKIDAR_USEPOLLING=true in a .env file (technically the same thing as this solution) to no effect.
Reacted by Sushmit Sagar Gaur, Thomas Jungblut, Omer Buyukguclu, xshameem, C.Jay Martin, Mihir Patel, Dark Litss, Arath Astorga, TebogoNkomondoJ, lawrence910426 and 12 more
This didn't solve the issue for me. My situation remains same as described in the original issue description.
I have also tried the CHOKIDAR_USEPOLLING=true in a .env file (technically the same thing as this solution) to no effect.
I am facing the Same Issue.
Reacted by Sofiane BOUMEDINE, Thomas Jungblut, xshameem, mirandanc, Akbar moshur Alam, DEKMag, Johannes Xerxes Dalogdog, Gabriel Nicolau and Martin Garbade
This didn't solve the issue for me. My situation remains same as described in the original issue description.
I have also tried the CHOKIDAR_USEPOLLING=true in a .env file (technically the same thing as this solution) to no effect.
I am facing the Same Issue.
Same Issue here as well. Are you on Windows 11?
Reacted by Hasan Ghomi, lawrence910426, mirandanc, bradib0y, Johannes Xerxes Dalogdog and Gabriel Nicolau
This didn't solve the issue for me. My situation remains same as described in the original issue description.
I have also tried the CHOKIDAR_USEPOLLING=true in a .env file (technically the same thing as this solution) to no effect.
I am facing the Same Issue.
Same Issue here as well. Are you on Windows 11?
Yes I am. My projects folder was placed on Desktop means in C: drive after some research I found out I need to place the project in linux folder itself. So I moved the project to linux folder i.e., "wsl\Ubuntu\home{$username}" and it worked even without CHOKIDAR_USEPOLLING=true . hope it helps.
Reacted by Cabba, Fred Lee, Jéssica Ramírez, Parsa Salavati, Kasper Pawłowski, Tuan Dinh, Wiktor Czajkowski, Kavindu Vindika, Ngondo, archit singh and 4 more
Version 5.x.x of react-scripts does not work with CHOKIDAR_USEPOLLING because there was a breaking change in webpack and that variable is no longer supported. The newly added variable WATCHPACK_POLLING has to be used instead.
What worked the best for me was to reinstall react-scripts, I first tried to replace the latest version with the 4.0.3, it worked, then I tried the latest (5.0.1) again and it also worked. However, make sure to MANUALLY trigger the first refresh of your app after reinstalling react-scripts, otherwise the auto refresh will not work.
due to some answer in stackoverflow, that I'm so sorry for forgetting who answered that, I could fix this bug because I set up my wsl from version 2 to version 1.
Here is my command in Powershell (with administrator, absolutely)
Version 5.x.x of react-scripts does not work with CHOKIDAR_USEPOLLING because there was a breaking change in webpack and that variable is no longer supported. The newly added variable WATCHPACK_POLLING has to be used instead.
Version 5.x.x of react-scripts does not work with CHOKIDAR_USEPOLLING because there was a breaking change in webpack and that variable is no longer supported. The newly added variable WATCHPACK_POLLING has to be used instead.
I recently installed WSL 2 but when I create an app using create-react-app and use npm start the app was’t reloaded when I edited and saved some file
Describe the solution you'd like
I want to use Hot Reloading on my Projects located in Windows file system.
WSL2 changed the file sharing protocol, from using their own custom developed protocol using the 9P protocol, which does not support file changes event for Create React App.
Describe alternatives you've considered
To FIX this issue : You can put your code on the Linux file system (example : in your user’s home directory ), and access these files through the WSL share, \wsl$\DISTRO_NAME from Windows.
Version 5.x.x of react-scripts does not work with CHOKIDAR_USEPOLLING because there was a breaking change in webpack and that variable is no longer supported. The newly added variable WATCHPACK_POLLING has to be used instead.
Activity
bennettdams commentedon Dec 17, 2020
Did you try it out with the
CHOKIDAR_USEPOLLINGenvironment variable?PrajjwalDatir commentedon Dec 18, 2020
@bennettdams
CHOKIDAR_USEPOLLINGis if I'm running my react app inside a VM right!?I tried all other troubleshooting methods, none of them worked.
I'm not running my project inside VM so why & how do I use
CHOKIDAR_USEPOLLING=true?bennettdams commentedon Dec 18, 2020
@PrajjwalDatir "VM" is just the example the CRA team used for their documentation there. Really, Chokidar is a file watcher for Node, so it handles the "proxy" part of your development setup (remote container, WSL, VM, etc.).
How do I know? Just last week I set up a project with VS Code's Remote Containers, which had exactly the same problem you described here. With Chokidar, my changes are actually noticed by VS Code.
To quickly test it out, just change your start script in the
package.jsonto{ ... "start": "CHOKIDAR_USEPOLLING=true react-scripts start" ... }PrajjwalDatir commentedon Dec 19, 2020
Thanks! It works now 🕺
#10197 is the parent issue of this, so I'm closing this issue.
For future readers,
Inside your
package.jsonfind
and replace it with
[-]WSL 2: ReactJS not reloading after saved.[/-][+]WSL 2: ReactJS not reloading after saved. [Solved][/+]Update "start" to auto-reload on WSL
vivek-settlemint commentedon Oct 12, 2021
I moved my code from the mounted file system to ubuntu file system in
~/homeand it worked!resyfer commentedon Oct 13, 2021
I believe this issue happens for stuff that use the Chokidar package... React, Vue, Nodemon....all don't reload on save
nurshom commentedon Dec 29, 2021
This didn't solve the issue for me. My situation remains same as described in the original issue description.
I have also tried the
CHOKIDAR_USEPOLLING=truein a.envfile (technically the same thing as this solution) to no effect.sushmitg commentedon Dec 31, 2021
I am facing the Same Issue.
archit11111 commentedon Jan 2, 2022
Same Issue here as well. Are you on Windows 11?
sushmitg commentedon Jan 3, 2022
Yes I am. My projects folder was placed on Desktop means in C: drive after some research I found out I need to place the project in linux folder itself. So I moved the project to linux folder i.e., "wsl\Ubuntu\home{$username}" and it worked even without
CHOKIDAR_USEPOLLING=true. hope it helps.25 remaining items
adityavartak07 commentedon Jun 26, 2022
Dude man was searching for a solution, since 4 hrs, finally this worked. Thanks man.
lucaszarza commentedon Jul 16, 2022
I had the same problem with hot reaload on WSL, after using the "CHOKIDAR_USEPOLLING=true" on package-json:
"dev": "CHOKIDAR_USEPOLLING=true vue-cli-service serve",It Works, althought it's taking a lot of time to show the changes on screen.
P.S. I'm using vue
but thanks anyway!
danielcaze commentedon Aug 3, 2022
how do I do this?
87prashant commentedon Aug 3, 2022
@danielcaze
Not sure about that, but you can try this: #10253 (comment)
It worked for me👍
ianpegg commentedon Sep 26, 2022
After a couple of hours of headscratching this solved the issue for me in my Homestead VM. Thank you!
HuyyNguyenz commentedon Sep 29, 2022
Thank you so much, it's finally working again ^^
jerlam06 commentedon Oct 27, 2022
What worked the best for me was to reinstall react-scripts, I first tried to replace the latest version with the 4.0.3, it worked, then I tried the latest (5.0.1) again and it also worked. However, make sure to MANUALLY trigger the first refresh of your app after reinstalling react-scripts, otherwise the auto refresh will not work.
hoa-nguyen-bk commentedon Nov 21, 2022
due to some answer in stackoverflow, that I'm so sorry for forgetting who answered that, I could fix this bug because I set up my wsl from version 2 to version 1.
Here is my command in Powershell (with administrator, absolutely)
olsonperrensen commentedon Dec 7, 2022
Thank you! Working now.
Edit: Docker Toolbox also supported!
chore: add missing environment variable to watch properly
gaurpulkit commentedon Mar 15, 2023
If anyone is using WSL 2 and react-scripts, then THIS IS THE WAY!
[frontend] Fix: auto reload
independenceee commentedon Jul 4, 2023
WATCHPACK_POLLING=true in .env files
GabrielFMPinheiro commentedon Jan 23, 2024
Thx so much! This worked using colima on Mac
LanPodder commentedon Apr 27, 2025
Ive struggled with reloading a react project with docker. In my compose.yml file adding
Didnt enable reloading through docker.
Changing this to
Fixed that.
My question now is why is there no documentation on WATCHPACK_POLLING?