Setting up for local Windows development
Development on Windows requires specific configuration using Windows Subsystem for Linux (WSL). This guide will help you set up your Windows environment correctly to avoid common issues.
1. Enable WSL
First, enable the required Windows features:
- Open Start Menu -> Settings -> Optional features -> More Windows features
- Check these boxes:
- “Windows Subsystem for Linux"
- "Windows Sandbox”
- Click OK and restart when prompted
2. Install WSL
- Open PowerShell as Administrator
- Ensure you have the latest WSL:
wsl --update
- Install WSL:
wsl --install
3. First-Time Ubuntu Setup
After WSL installation completes:
- Open Start Menu and launch Ubuntu
- Create your Linux username and password when prompted
- Update the system:
sudo apt update && sudo apt upgrade -y
4. Install Windows Terminal
- Install Windows Terminal Preview from: https://aka.ms/terminal ↗
- Configure settings:
- Click the chevron (▼) next to tabs
- Go to Settings -> Startup
- Set “Default profile” to Ubuntu
- Set “Default terminal application” to Windows Terminal Preview
5. Configure Node.js in WSL
Launch Windows Terminal and run these commands:
# Install build dependenciessudo apt-get install -y build-essential curl git
# Install nodenvgit clone https://github.com/nodenv/nodenv.git ~/.nodenvsudo ln -vs ~/.nodenv/bin/nodenv /usr/local/bin/nodenv
# Compile dynamic bash extension (can safely fail)cd ~/.nodenv && src/configure && make -C src || truecd ~/
# Add nodenv to PATH and initializeecho 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrcecho 'eval "$(nodenv init -)"' >> ~/.bashrcsource ~/.bashrc
# Install pluginsmkdir -p "$(nodenv root)"/pluginsgit clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-buildgit clone https://github.com/nodenv/nodenv-aliases.git $(nodenv root)/plugins/nodenv-aliases
# Install Node.jsnodenv install 20.12.1nodenv global 20
# Configure system-wide accesssudo ln -vs $(nodenv root)/shims/* /usr/local/bin/
6. Configure VS Code
- Install VS Code from https://code.visualstudio.com/download ↗
- During installation, ensure “Add to PATH” is checked
- Install required packages in WSL:
sudo apt-get install wget ca-certificates
-
Install VS Code extensions:
- Launch VS Code
- Install the WSL extension
- Install the Remote Development extension pack ↗
-
Connect to WSL:
- Open Command Palette (CTRL+SHIFT+P)
- Type “WSL” and select “WSL: Connect to WSL”
7. Project Setup in VS Code
Open your project:
- In VS Code, go to File -> Open Folder
- Browse to your project directory (use
/home/your-username/...
)
Install dependencies:
- In VS Code, go to Terminal -> New Terminal
- Run:
nodenv install -snpm install --include=dev
Start development server in debug mode:
- Select debugger in the left sidebar of VS Code
- Click “Start debugging”
- If “astro is ready” message is missing:
- Stop debugging
- Start debugging again