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.

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)