'npm start hangs, does not sync changes (create-react-app on WSL)

I am new to web dev and am trying to follow the React tutorial. I have followed it successfully in the past on my machine. I am using Ubuntu 20.04 in WSL.

When I run:

npx create-react-app helloworld cd helloworld npm start

I get:

[email protected] start /mnt/d/ProgrammingProjects/helloworld

react-scripts start

And it hangs there for about 5 minutes before the localhost opens. Once the localhost is open, it does not sync changes when I edit and save the App.js file.

I have tried completely uninstalling and reinstalling node and npm.



Solution 1:[1]

I was also having the problem with hot reloading in WSL2 . I tried almost every solution present on github , stackoverflow and where not . Trying to fix it from CHOKIDAR_USEPOLLING=true to setting FAST_REFRESH = false in .env to changing network setting using netsh and what not for 2 days . finally decided to revert to WSL1. I think it's because WSL 2 is running as a hyper-v virtual machine. If you're using WSL2 you should revert to WSL1 for now.

wsl --set-version Ubuntu-18.04 1

Run the above command in Powershell. And check version of WSL after using

wsl -l -v

if it's version 1 now you are good to go.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vibhanshu chauhan