0

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:

helloworld3@0.1.0 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.

jasminee
  • 1
  • 2
  • Do you happen to have npm/node installed in both Windows and WSL/Linux? If so, see [this answer](https://stackoverflow.com/a/63458916/11810933). – NotTheDr01ds Jan 23 '21 at 21:35
  • I did have it and tried uninstalling, that didn't work unfortunately. thanks though! – jasminee Jan 24 '21 at 02:04
  • Have you rebooted at any point since trying it? Sometimes the Windows->WSL localhost port mapping seems to break down, and I'm not quite sure why. You don't *have* to reboot, but if you haven't, try a `wsl --shutdown` from PowerShell or cmd (after saving and exiting out of everything, of course). – NotTheDr01ds Jan 24 '21 at 05:10
  • Just as a point of reference, I did try your exact scenario on WSL2/Ubuntu 20.04 and the browser opened up to the react sample within a second or so. Hot reloading/sync worked after editing as well. – NotTheDr01ds Jan 24 '21 at 05:11
  • thanks for testing that out. It seems better now, but I'll try also try shutting down wsl next time this happens. – jasminee Jan 25 '21 at 23:36

1 Answers1

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.