Skip to content

Install OpenCode on Windows With WSL

Install and run OpenCode on Windows using WSL. Node setup, install, adding a cheap provider, config location, and the WSL-specific gotchas to avoid.

MGMCSA Guru Team August 5, 2026 3 min read
Installing and running OpenCode inside WSL on Windows

OpenCode is a free, open-source terminal coding agent, and on Windows it’s happiest in WSL — a clean Unix-like shell where its config, providers, and file operations all behave as the docs assume. This guide installs and runs OpenCode in WSL, including adding a cheap model provider, with the WSL details worth knowing.

If WSL isn’t installed yet, start with the WSL install guide. For the provider config in depth, see OpenCode custom providers.

Step 1: Node in WSL

OpenCode installs via npm, so install Node inside WSL with nvm:

sudo apt update && sudo apt install -y curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts

Step 2: Install OpenCode

npm install -g opencode-ai
opencode --version

Step 3: Add a cheap provider

Add a provider to opencode.json using the OpenAI-compatible adapter. DeepSeek example:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "deepseek": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "DeepSeek",
      "options": {
        "baseURL": "https://api.deepseek.com/v1",
        "apiKey": "{env:DEEPSEEK_API_KEY}"
      },
      "models": { "deepseek-chat": { "name": "DeepSeek Chat" } }
    }
  },
  "model": "deepseek/deepseek-chat"
}

Export the key in your profile:

echo 'export DEEPSEEK_API_KEY="sk-your-key"' >> ~/.bashrc
source ~/.bashrc
opencode

Swap the block for GLM, Kimi, MiniMax, or StepFun.

Step 4: Work in the Linux file system

For big repos, copy the project into your Linux home so OpenCode’s file operations stay fast:

cp -r /mnt/c/Users/YourName/myproject ~/myproject
cd ~/myproject
opencode

See access your Windows files from WSL.

OpenCode in WSL essentials

nvm install --lts Node inside WSL
npm i -g opencode-ai Install OpenCode
opencode.json in Linux home Provider config
{env:VAR} + key in ~/.bashrc Cheap model auth
project in ~ Faster file operations

WSL gotchas

  • opencode: command not found — reopen the shell after install.
  • Provider not found — the provider key must match the model prefix.
  • Config not loading — check for a stray OPENCODE_CONFIG variable overriding it.
  • Slow on big repos — move the project into your Linux home.

OpenCode on WSL checklist

  • WSL installed; Node via nvm inside WSL
  • OpenCode installed (npm i -g opencode-ai)
  • Provider block in opencode.json (Linux home)
  • API key exported in ~/.bashrc
  • Active project in Linux home; launched with opencode

Wrapping up

On Windows, install OpenCode in WSL: Node via nvm, npm i -g opencode-ai, a provider block in opencode.json, and your key in ~/.bashrc. Keep config and active projects in your Linux home for clean permissions and speed. From there it runs on any cheap model you configure.

For the provider details, see OpenCode custom providers and pick a backend like DeepSeek + OpenCode.

Frequently asked questions

Should I install OpenCode in WSL on Windows?

WSL is the smoother choice for a terminal agent. OpenCode assumes a Unix-like shell, so WSL gives clean paths, environment variables, and config handling. It runs on native Windows too, but WSL avoids several quirks.

Do I need Node in WSL for OpenCode?

Yes, if installing via npm. Install Node inside WSL with nvm, then npm install -g opencode-ai. The binary and config then live in your Linux environment.

Where does the OpenCode config live?

OpenCode reads a global config (commonly ~/.config/opencode/opencode.json) and a project-level opencode.json. Keep them in your Linux home in WSL. The OPENCODE_CONFIG variable can override both.

How do I add a cheap model in WSL?

Add a custom provider in opencode.json using @ai-sdk/openai-compatible with the provider's base URL and an {env:VAR} key, then export that key in your shell profile. See the per-model OpenCode guides.

Why keep my project in the Linux file system?

Agent file operations are faster in your Linux home than across /mnt/c. For big repos, copy the project into ~ for the session to avoid the cross-boundary slowdown.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.