Skip to content

Node not found in WSL environment with nvm #32495

@hanfengcan

Description

@hanfengcan

Description

Environment

  • Platform: Linux (WSL2)
  • Distribution: WSL_DISTRO_NAME=opencode
  • Node Version: v24.15.0 (installed via nvm at ~/.nvm/versions/node/v24.15.0/bin/node)
  • npm Version: v11.12.1
  • Shell: bash

Problem

When OpenCode executes bash commands, which node fails and node --version cannot be found, even though nvm is installed.

Environment Variables at Runtime

HOME=/home/user
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib
npm_config_user_agent=npm/undefined node/v24.3.0 linux x64 workspaces/false

Expected

  • which node should return a valid path
  • node --version should work

Actual

  • which node → no output (node not found)
  • node --version → command fails
  • nvm node exists at /home/hanfengcan/.nvm/versions/node/v24.15.0/bin/node
  • npm_config_user_agent shows node/v24.3.0 instead of nvm's v24.15.0

Root Cause

The PATH does not include nvm's node bin directory. nvm is not automatically sourced in OpenCode's bash execution context.

Steps to Reproduce

  1. Install node via nvm in WSL
  2. Run OpenCode
  3. Execute any bash command that checks for node

Additional Context

Running source ~/.nvm/nvm.sh && nvm use node makes node available, but this requires manual intervention in every command.

Plugins

No response

OpenCode version

1.17.7

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Ubuntu 24

Terminal

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions