Wrong node version with local convex
I'm probably doing something stupid here, but I've been stuck on this for a couple of days.
When using AI town and running the local server, the convex backend is unable to connect. The server client side and server side errors are attached. The server error is:
I've tried to use nvm us with 18,19 and 20 to see if that fixes it but I get the same error. The client side command is:
.
I've tried multiple fresh checkouts and it persists. Any thoughts?
7 Replies
Have you done the
nvm use 18
in the shell where you're running ./convex-local-backend
and where you're running just convex dev
or just in one of them?I believe both but let me verify
Ah. that worked! Thank you! I can add this to the readme. Should we recommend 18?
I think the issue might be that I was running the local convex in a separate directory
fwiw I couldn't repro this using node 21 on both (in the same directory)
ok that must be it. I can just add a caution that they need to be in the same directory.
thanks @ian !
I ran into his issue too and found that the code has node@18 hardcoded. Unless I'm missing something, the code literally has the check logic for the pattern
v18.
hardcoded, so any other node version than v18 would fail. I had to get around this issue by creating a dedicated conda environment that installs node v18, which is inefficient. Maybe there was a reason why it's pinned to v18, but if not, would be good to get rid of the restriction and instead say something like "the version is greater than or equalt to 18" Here's the hardcoded part https://github.com/get-convex/convex-backend/blob/99ad0fe0520633af9f8c1a4e7634d0d1a938e51c/crates/node_executor/src/local.rs#L88-L94GitHub
convex-backend/crates/node_executor/src/local.rs at 99ad0fe0520633a...
Open source single-machine version of the Convex backend - get-convex/convex-backend
Since "use node" code in Convex currently uses Node.js 18 in AWS Lambda, the local runner is hardcoded to copy this. When upgrade to Node.js 20 in Lambda or potentially allow multiple versions (which would be configured in the Convex code) the runner will need to match this version, or have whichever version the code uses installed.
Minimally we need to update the README in AI town to reflect this.
I just merged a PR to add this to the README.