Setting Up WSL2
Windows Subsystem Linux (WSL) is not automatically enabled on windows. So, to start, we need to enable it!
Enable the Windows Subsystem for Linux (WSL) and Virtual Machine Platform
Now that we know your computer is ready for the rest of the environment setup, we need to enable two more settings before moving on. We’ll be using the Windows Subsystem for Linux (WSL) and the Virtual Machine Platform to create a space on our computer for our Ubuntu operating system.
Action Item: Enable Windows Subsystem for Linux (WSL) and Virtual Machine Platform Settings
- Open the "Turn windows features on and off" application using the "Start" menu
- Check the box next to "Virtual Machine Platform"
- Check the box next to "Windows Subsystem for Linux"
- Click "OK" to save your work; your computer should restart
<iframe width="560" height="315" src=" Check Your Workhttps://www.youtube.com/embed/FNW1CktP_m8" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
If you can check both of those checkboxes and your computer restarts, continue below. Otherwise, reach out to your teaching team for next steps.
Set up the "Ubuntu" Application
After you have installed the "Ubuntu" application from the Microsoft Store and enabled Windows Subsystem for Linux (WSL) and the Virtual Machine Platform, we have to set up the Ubuntu operating system.
Action Item
- Open the "Ubuntu" application using the "Start" menu
- When it says "Enter new UNIX username:" add a simple username and press
<Enter>
(Note: usernames may not start with a number, usernames may not include capital letters) - Where it says "New password:" add a simple password and press
<Enter>
(Note: you will not see any text when you are typing your password.) - Where it says "Retype new password:" retype the same password from before and
press
<Enter>
- The terminal should output "Installation successful!" and then print about 50 lines that you can ignore
<iframe width="560" height="315" src=" Check Your Workhttps://www.youtube.com/embed/ZFXI7vGFdng" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Now, the last line in your "Ubuntu" application should say your username + "@DESKTOP" + some random numbers and letters. If you see that, continue below.
Update the Windows Subsystem for Linux (WSL) to WSL 2
Now that we have the Windows Subsystem for Linux (WSL) enabled and we have the "Ubuntu" application installed, we can update WSL to version 2 and update the "Ubuntu" application to use WSL 2.
Action Item
- Download the WSL Update file by visiting the following webpage in your browser: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
- Open the file, follow the prompts, allow the program to make changes to your device, and click "Finish"
- Search for the "Command Prompt" application using the "Start" menu
- Select "Run as administrator" from the right side of the search window
- Allow the program to make changes to your device and wait for the "Command Prompt" application to open
- Type
wsl --set-default-version 2
into the terminal and press<Enter>
(Note: you should see a message starting with "For information on key differences…") - Type
wsl --set-version Ubuntu 2
into the terminal and press<Enter>
- Wait for the "Conversion complete" or "This distribution is already the requested version" message in the terminal
<iframe width="560" height="315" src=" Check Your Workhttps://www.youtube.com/embed/7IxV_ARTAoo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/dvqSkrK-q6g" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
If you saw the "Conversion complete" or "This distribution is already the requested version" message in the "Command Prompt" application, close the "Command Prompt" application and continue below.
Note: If you encounter an error message that you need to enable the Virtual Machine Platform, but you've already enabled it, you may not be able to use WSL2. However, you may still be able to use WSL1. Run
wsl --set-default-version 1
, then runwsl --set-version Ubuntu 1
. Wait for the "Conversion complete" or "This distribution is already the requested version" message in the terminal, then continue on with these instructions.
Configure VS Code to Work with WSL
Action Item
- Open the "Visual Studio Code" application using the "Start" menu
- Click "View" in the toolbar, then click "Extensions" in the dropdown menu, or
use the shortcut
<Control>
+<Shift>
+ X - Search for "Remote - WSL" and click on the item in the list with the same name (Note: the description should start with "Open any folder in the Windows Subsystem for Linux (WSL) …")
- Click the green "Install" button
- Click "Terminal" in the toolbar, then click "New Terminal" (Note: a new terminal should appear at the bottom of your VS Code window)
- Click on the dropdown in the terminal that says "1: powershell" and choose "Select Default Shell"
- A dropdown should appear at the top of your VS Code window
- Click on "WSL Bash" to enable VS Code to display your Ubuntu terminal
- Close the "Visual Studio Code" application
- Open the "Ubuntu" application using the "Start" menu
- Type
code
and press<Enter>
<iframe width="560" height="315" src=" Check Your Workhttps://www.youtube.com/embed/wUmNR1ip7ck" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/giY_9z096vo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
If the "Visual Studio Code" application opens when you type code
in the
"Ubuntu" application, continue to the next lesson, Installing Node on WSL2.