Copilot in vim when using multiple node versions

This is just a quick note to myself and to fellow people who may encounter this issue.

If you use a node version manager such as nvm/asdf/mise, you may have a situation where you need a given version to work with a project, but that version is too old to support Copilot.

This shows up as an error in Vim

Copilot: Node.js too old. Upgrade to 22.x or newerCode language: CSS (css)

Or, if you switch while Vim is already running, with copilot just silently not working anymore.

To solve this “nodejs too old” error, you can put this in your vimrc

let g:copilot_node_command='/opt/local/bin/node22' # or whatever absolute pathCode language: PHP (php)

I rely on the right macports version here but you can just as well use a mise binary

let g:copilot_node_command=/Users/riffraff/.local/share/mise/installs/node/22.22.0/bin/nodeCode language: JavaScript (javascript)

Now just restart vim and all should be good.

HTH, HAND.