As a budding developer, you started with simple, straightforward tools to build your foundational skills. Now, it's time to elevate your development environment by transitioning to WSL 2 (Windows Subsystem for Linux). This upgrade provides a more powerful, flexible environment, enabling you to tackle advanced projects with confidence.
Why Choose WSL 2?
Think of WSL 2 as having the best of both worlds: the power of Linux combined with the familiarity of Windows. It offers:
- A full Linux kernel within your Windows system
- Improved file system performance
- Compatibility with Linux development tools and utilities
- Seamless integration between Linux and Windows environments
It's like adding a powerful new engine to a car you're already comfortable driving, making it faster and more efficient.
Step-by-Step Guide to Setting Up WSL 2
-
Check Computer Requirements
Ensure your system supports WSL 2:
- Press Windows + R, type
winver, and press Enter. - For Windows 10:
- x64: Version 1903 or higher
- ARM: Version 2004 or higher
- Check system type: Open PowerShell and run
systeminfo | find "System Type". - For Windows 11, WSL 2 is already supported.
To install WSL, open PowerShell as an administrator and run
wsl --install. Restart your computer when prompted. - Press Windows + R, type
-
Enable WSL and Virtual Machine Features
Run the following commands in PowerShell as an administrator:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestartRestart your computer.
-
Download the Linux Kernel Update Package
Based on your system type (x64 or ARM), download and install the appropriate Linux kernel update package. Use the
systeminfocommand if you're unsure of your system type. -
Set WSL 2 as Default
In PowerShell, run
wsl --set-default-version 2. -
Install Your Linux Distribution
From the Microsoft Store, search for and install a Linux distribution such as Ubuntu 22.04.3 LTS. Upon launching, complete the setup:
- Provide a UNIX username (lowercase, no spaces).
- Set and confirm a password.
Update your system using:
sudo apt update && sudo apt upgrade -
Set Default Distribution
If you installed multiple distributions, set your default using:
wsl --list wsl --setdefault -
Configure Git
Set up Git in Ubuntu:
git config --global user.name "" git config --global user.email " " git config --global init.defaultBranch main Verify your configuration with
git config --list. -
Install nvm, Node.js, and Mocha
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bashUpdate your shell configuration by adding:
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. [ -s "$NVM_DIR/bash_completion" ] && \.Install Node.js:
nvm install 18Install Mocha:
npm -g install mocha
Real-World Applications and Benefits
WSL 2 is ideal for developers transitioning into more advanced workflows. Whether you're running Docker containers, testing server-side code, or exploring Linux-exclusive tools, WSL 2 bridges the gap between Windows and Linux, allowing for seamless development.
Think of it as upgrading from a basic toolkit to a professional-grade workshop, enabling you to tackle projects with precision and efficiency.
Further Learning
Explore these topics to deepen your understanding:
- Setting up Docker on WSL 2
- Using VS Code with WSL 2 for a seamless development experience
- Understanding Linux commands and shell scripting