[BUG] Claude Code always uses system version of node, rather than project-specific version installed via nodenv
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version:
0.2.45 (Claude Code) - Operating System:
OSX 15.3.2 - Terminal:
Kitty 0.37.0 with fish shell 3.7.1
Bug Description
Claude code always uses the system version of node, which is incorrect if there is a more specific project version it should be using.
I am using nodenv to manage my node version. This means I have nodenv installed, and a .node-version file in the root of my project. My shell will automatically pick this up, and switch to the correct version of node.
The same is true for other tools like rbenv, phpenv, pyenv, goenv etc.
All of these tools are bootstrapped in your shell, i.e. in ~/.config/fish/config.fish I have
status --is-interactive; and source (rbenv init -|psub)
status --is-interactive; and source (phpenv init -|psub)
status --is-interactive; and source (nodenv init -|psub)
status --is-interactive; and source (pyenv init -|psub)
status --is-interactive; and source (goenv init -|psub)
Claude Code claims (to me) to be running zsh shell, and is not bootstrapping any of these tools.
I asked Claude how it could boostrap these tools, and it said it would remember to do so for the future using
export PATH="$HOME/.nodenv/bin:$PATH" && eval "$(nodenv init -)"
Except that it doesn't seem to actually work. I've tried adding this to my CLAUDE.md, but that also seems to not have effect:
````markdown
Environment
Ensure you run any npm commands with the correct version of Node.
nodenv is used locally to manage Node
versions. The .node-version file in the project root specifies the correct
version.
Make sure you setup the correct version of Node with nodenv:
export PATH="$HOME/.nodenv/bin:$PATH" && eval "$(nodenv init -)"
````
Steps to Reproduce
Have nodenv installed and system node installed, but have different versions.
Note that starting Claude and asking it to node --version, will output system version of node, rather than the project-specific version dictated by .node-version file in the project.
Expected Behavior
If there is a .node-version file it should be using that version of node, especially if I've already instructed it on how to switch to the correct node version via CLAUDE.md
Actual Behavior
It used the system version of node, and seemed to ignore instructions on how to switch to project-specific nodenv version of node.
Additional Context
<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->
This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗