[BUG] Claude runs vitest in Node v18 but I installed v22 in my PC

Resolved 💬 5 comments Opened Mar 14, 2026 by sovetski Closed Apr 13, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude is not able to run npm run test:run it says:

Found it — Node 18.19.1 but Vitest 4 requires Node 20+. The package.json even says "engines": { "node": ">=20 <=23" }.

nvm has Node 22.13.1 installed but the shell is using Node 18.19.1 (the system version). The default is set to 22, so why is node --version showing v18?

Let me check what's happening. The make test runs npm run test:run which uses the system Node (not the nvm-managed one). The current shell has Node 18 as the system default.

Actually wait, looking at the nvm output: ->     v22.13.1 * and system * - the -> indicates the current shell is using v22.13.1, and system * also has the asterisk.

But node --version is returning v18.19.1, which suggests the Bash tool isn't sourcing nvm's initialization script, so it's falling back to the system Node in the PATH. I should try sourcing nvm before running vitest to ensure it uses the correct version.

What Should Happen?

It must use the system Node version

Error Messages/Logs

Steps to Reproduce

Create a project with vitest and run the tests

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.50 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗