Windows Dev Environment Fundamentals
The most important aspects of setting up a development environment on Windows are SDK installation, environment variable (PATH) configuration, and toolchain integration. Unlike Linux or macOS, Windows historically lacked a built-in package manager, so manual management of environment variables is often necessary.
This article covers how to systematically configure SDKs, tools, and PATH needed for development on Windows.
Understanding Environment Variables and PATH
Environment variables are key-value pairs that the operating system passes to programs. PATH is the most important variable — it’s the list of directories where the terminal searches for executables.
# Check current PATH
$env:PATH -split ';' | ForEach-Object { $_ }
# Sample output:
# C:\Windows\system32
# C:\Windows
# C:\Program Files\Git\cmd
# C:\Program Files\nodejs
# C:\Users\username\AppData\Local\Programs\Python\Python312\Scripts
# Find the execution path of a specific command
Get-Command git
# Sample output:
# CommandType Name Version Source
# Application git 2.44.0 C:\Program Files\Git\cmd\git.exe
# Check environment variables
$env:JAVA_HOME
$env:GOPATH
$env:PYTHON_HOME
How to Set Environment Variables
Environment variables are divided into user level and system level. Development tools are typically set at the user level.
# Set user-level environment variable (permanent)
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk-21", "User")
[Environment]::SetEnvironmentVariable("GOPATH", "D:\Go", "User")
# Add path to user PATH (permanent)
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$newPath = "$currentPath;C:\Program Files\Java\jdk-21\bin"
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
# Apply temporarily to current session only
$env:JAVA_HOME = "C:\Program Files\Java\jdk-21"
$env:PATH += ";C:\Program Files\Java\jdk-21\bin"
# Verify changes (open a new terminal for permanent settings to take effect)
refreshenv # Available if Chocolatey is installed
You can also configure via GUI: Win+S -> search “environment variables” -> “Edit the system environment variables” -> “Environment Variables” button
Git Installation and Configuration
Git is the foundation of nearly every development workflow. On Windows, install Git for Windows.
# Install via winget
winget install Git.Git --silent
# Basic configuration
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
# Line ending settings (important on Windows)
git config --global core.autocrlf true
# true: convert LF->CRLF on checkout, CRLF->LF on commit
# Set default editor
git config --global core.editor "code --wait"
# Generate SSH key
ssh-keygen -t ed25519 -C "email@example.com"
# Generated public key: C:\Users\username\.ssh\id_ed25519.pub
# Verify configuration
git config --global --list
# Sample output:
# user.name=Your Name
# user.email=email@example.com
# core.autocrlf=true
# core.editor=code --wait
Node.js Setup (nvm-windows)
Use nvm-windows to manage multiple Node.js versions.
# Install nvm-windows
winget install CoreyButler.NVMforWindows
# Check available Node.js versions
nvm list available
# Sample output:
# | CURRENT | LTS |
# | 23.5.0 | 22.12.0 |
# | 23.4.0 | 20.18.1 |
# Install and use Node.js LTS
nvm install 22.12.0
nvm use 22.12.0
# List installed versions
nvm list
# Sample output:
# * 22.12.0 (Currently using 64-bit executable)
# 20.18.1
# Verify
node --version # v22.12.0
npm --version # 10.9.2
# Install global packages
npm install -g typescript tsx pnpm yarn
Python Setup
Install Python via the official installer or winget. The “Add to PATH” option is critical.
# Install via winget
winget install Python.Python.3.12
# Verify installation
python --version # Python 3.12.x
pip --version # pip 24.x
# Upgrade pip
python -m pip install --upgrade pip
# Create virtual environment
python -m venv D:\projects\myproject\.venv
# Activate virtual environment
D:\projects\myproject\.venv\Scripts\Activate.ps1
# Prompt changes to (.venv)
# Install useful global tools
pip install pipx
pipx install poetry
pipx install black
pipx install ruff
Java Setup
Java has multiple distributions (Oracle, Adoptium, Amazon Corretto, etc.). Adoptium (Eclipse Temurin) is recommended.
# Install Adoptium JDK 21
winget install EclipseAdoptium.Temurin.21.JDK
# Set JAVA_HOME
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Eclipse Adoptium\jdk-21", "User")
# Add to PATH
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
[Environment]::SetEnvironmentVariable("Path", "$currentPath;%JAVA_HOME%\bin", "User")
# Verify (in a new terminal)
java --version
# Sample output:
# openjdk 21.0.5 2024-10-15 LTS
# OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)
javac --version
# javac 21.0.5
Build Tool Installation
Build tools like C/C++ compilers or Make are sometimes needed.
# Visual Studio Build Tools (C/C++ compiler)
winget install Microsoft.VisualStudio.2022.BuildTools
# After install, select "Desktop development with C++" workload
# Or via command line:
# vs_buildtools.exe --add Microsoft.VisualStudio.Workload.VCTools
# GNU Make (via Chocolatey)
choco install make -y
# CMake
winget install Kitware.CMake
# Rust
winget install Rustlang.Rust.MSVC
# Verify:
rustc --version
cargo --version
Dev Environment Auto-Setup Script
An automation script for quickly setting up a development environment on a new PC.
# setup-dev-env.ps1
# Requires admin privileges
Write-Host "=== Windows Dev Environment Auto-Setup ===" -ForegroundColor Cyan
# 1. Install essential tools
$tools = @(
"Git.Git",
"Microsoft.VisualStudioCode",
"Microsoft.WindowsTerminal",
"CoreyButler.NVMforWindows",
"Python.Python.3.12",
"EclipseAdoptium.Temurin.21.JDK",
"Docker.DockerDesktop"
)
foreach ($tool in $tools) {
Write-Host "Installing: $tool" -ForegroundColor Yellow
winget install $tool --silent --accept-package-agreements
}
# 2. Set environment variables
Write-Host "Setting environment variables..." -ForegroundColor Yellow
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Eclipse Adoptium\jdk-21", "User")
# 3. Git default configuration
Write-Host "Configuring Git..." -ForegroundColor Yellow
git config --global core.autocrlf true
git config --global core.editor "code --wait"
git config --global init.defaultBranch main
# 4. Install VS Code extensions
$extensions = @(
"ms-python.python",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-vscode-remote.remote-wsl"
)
foreach ($ext in $extensions) {
code --install-extension $ext
}
Write-Host "Setup complete! Please restart your terminal." -ForegroundColor Green
Troubleshooting PATH Issues
PATH-related problems are the most common issues in Windows development environments.
# When a command isn't found: check if the executable path is in PATH
where.exe python
# If there's no output, the Python path is not in PATH
# Remove PATH duplicates
$paths = [Environment]::GetEnvironmentVariable("Path", "User") -split ';' | Select-Object -Unique
[Environment]::SetEnvironmentVariable("Path", ($paths -join ';'), "User")
# Check PATH length (Windows may have a 2048 character limit)
$env:PATH.Length
# If over 1024, clean up unnecessary paths
Summary
Key points for setting up a Windows development environment:
- Environment variables: Use
[Environment]::SetEnvironmentVariable()for permanent settings,$env:for temporary - PATH management: Add SDK
bindirectories to PATH after installation, verify in a new terminal - Version managers: Use nvm-windows (Node.js), pyenv-win (Python), etc. for multi-version management
- Automation: Write setup scripts and manage them with Git for faster new PC configuration
- CRLF: Set Git’s
core.autocrlf=trueto prevent line ending issues - Build Tools: Install Visual Studio Build Tools for packages that require C/C++ native modules