Using NVM (Node Version Manager)
You may have a situation where the installed and set Node version on a CircleCI convenience image is not the one you need. You can install and swap node versions using Node Version Manager (NVM).
- 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 v12 nvm alias default 12.19.0 echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
The above is downloading Node v12 and then setting the default to be used for the rest of the job to v12.19.0. The run command should go towards the start of the job run and the only items that need to be modified are:
nvm install v12 nvm alias default 12.19.0
You will want to swap the install command to install the Node version you need and then the default command to set the specific version to use for the rest of the job.
Article is closed for comments.