Convex Node.js Setup
Convex local deployments require Node.js v18 to be installed for running "use node" actions, even though our application runs on Node v22.
Issue
Convex local deployments require Node.js v18 to be installed for running "use node" actions, even though our application runs on Node v22.
Solution
We've created a wrapper script (convex-dev.sh) that ensures Convex can find Node v18 when it needs it for actions, while keeping the rest of the application on Node v22.
Requirements
-
Install Node v18 using nvm if you haven't already:
nvm install 18 -
The wrapper script will automatically find and use Node v18 for Convex.
How it Works
- The
convex-dev.shscript adds Node v18 to the PATH specifically for Convex - This doesn't change your shell's Node version - it only affects Convex's runtime
- Your application continues to run on Node v22 as specified in
.nvmrc
Running the Backend
From the root directory:
bun dev:backend:localThe script will automatically handle the Node version switching for Convex.
Troubleshooting
If you see the error about Node v18 not being installed:
- Make sure you have nvm installed
- Run:
nvm install 18 - Try running
bun devagain