2024-12-22
This should install the latest version.
wsl --install --web-downloadIf you get stuck downloading Ubuntu during the installation you can cancel the process and just install it like this
wsl --install Ubuntu --web-downloadThis will list all the installed WSL distros.
wsl --listIn case you need to update later on.
wsl --update --web-downloadWrite wsl in terminal to access WSL.
Or if you using the Windows Terminal you can create a new tab by clicking the arrow next to the + button and select Ubuntu.
You should have at least version 2 of WSL installed.
wsl
wslinfo --wsl-version
#2.3.26This will mirror the network so if you have a windows process running on localhost:5173 it will be accessible on WSL as 127.0.0.1:1234.
And vice versa if you run for example Vite on WSL you can access it from your Windows browser at localhost:5173.
Create file .wslconfig in C:\Users\<username>\
[wsl2]
networkingMode=mirroredShutdown WSL after you made this file.
wsl --shutdownThen in WSL check if the networking mode is now mirrored.
wsl
wslinfo --networking-mode
# should say mirroredLink the existing Windows folder to the WSL linux folder. You need to run this from withing WSL
ln -s /mnt/c/path/to/windows/folder ~/desired/ubuntu/locationThis technically allows you to edit files in the linked Windows folder without connecting to WSL. But listening for file changes won't work. So for example Vite hot reloading won't work and you'd have to reload manually.
Follow this Stack Overflow answer to install Node.js and npm
Follow this official VS Code guide
Be warned that hibernating you computer without shutting down WSL might break it. Either it might become unresponsive or the mirrored networking will break.
So be carefule to always shutdown WSL before hibernating.
wsl --shutdownSometimes you might need to run this as admin.