how to switch node version
Open 💬 11 comments Opened Aug 19, 2025 by samuelstroschein
💡 Likely answer: A maintainer (seratch, member)
responded on this thread — see the highlighted reply below.
What is the type of issue?
Documentation is missing
What is the issue?
How can the node version that codex uses be changed?
It uses Node v18 by default. Prompting Codex to use nvm to switch the node version doesnt work. Here is a response that Codex gave
✓ Completed
└ ⌨️ echo "Checking for nvm..."; command -v nvm ||
echo "nvm not found"; echo "PATH=$PATH"; echo "Node
version:"; node -v
codex
I checked: this sandbox doesn’t have nvm available,
and Node is fixed at v18.16.0 for this session.
- nvm: not found
- PATH: shows host paths, but no nvm loader present
here
- node -v: v18.16.0
In another session on your machine you can absolutely
use nvm to switch to Node 22. In this Codex CLI
sandbox, the runtime is tied to the host image and
can’t be changed from inside the session. If you
want me to keep making progress here despite Node 18,
I can:
- Add a tiny vitest setup file to polyfill CustomEvent
so tests run under Node 18.
- Or flip specific tests to jsdom environment.
Where did you find it?
_No response_
11 Comments
A prompt like this can work for your use case, but it's inefficient. So, I'd recommend simply running
nvm useor having.nvmrcbefore starting acodexsession.Okay, so codex runs my shell correct?
If so, I need to figure out why it picks up v18 while my default is v22. The sandboxing stuff confused me. Codex said changing the node version is not possible because codex runs in a sandbox container which defaults to v18.
I'll try to fix the issue on my end tmr and report back
The bug seems to emerge because the default shell on mac os is zsh but codex runs in bash. The outcome are different environments.
Prob a good idea to use the default shell on the machine for codex?
nvm is just a bulky bash script which needs to be loaded for each shell session. So if you bootstrap nvm in zshrc file it might not be available because afaik codex executes commands in non-interactive mode.
Having same issue
Same here - using nvm to manage node, but sandbox is stuck on 18
Same here, i use node v22, but sandbox is on 18
Codex CLI in my case was using the Node.js binary from
/usr/local/bin/node. The workaround is to upgrade that global Node.js installation./usr/local/bin/nodeand Codex picks it upIt doesn't solve the fact that Codex should probably use nvm out of the box.
I had the same issue and solved. The reason is I had multiple node, and my zsh shell uses the homebrew one, but the sandbox uses the
/usr/local/bin/nodeone.Just tell codex to run the following commands, then you know the problem:
For me, since I use the homebrew one, so my solution is simply deleting the lower version
sudo rm -f /usr/local/bin/node.same here
This was the one thing that worked for me