Setting Node Version on Ruby CIMG

I’m using cimg/ruby:2.7.2-node. The default node version is v12.18.4. I’m trying to get 14.15. Is it possible to specify a different node version on the image? Should I use an orb somehow? Or should I install node myself directly in the config?

Hi @jolim,

This is a great question! There isn’t a way to directly change the node version during the spinup of the image, however after the container is established you can set a different version.

You have a few options, the first one being to use NVM to install and set the Node version, I recently wrote an article on how to accomplish that here:

So given the example you provided, this should install and set the version you are wanting:

      - run:
          name: Swap node versions
          command: |
            set +e
            wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
            export NVM_DIR="$HOME/.nvm"
            [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
            [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
            nvm install v14.15
            nvm alias default 14.15

            echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
            echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV

The other option, which you mentioned, is to utilize an Orb to accomplish the same thing. We have the Node orb here:

Hope that helps and let me know if you need anything else!