How to use a different nodejs version on atlassian bamboo build agent

  • fennng 

When you build a nodejs app, you may need to use a specific version of node for building. Either you want to match the running env or your node packages require a certain nodejs version.

On Azure DevOps, you can easily choose the node version by adding a nodejs installer step. With bamboo, there is no nodejs install, but this can be achieved easily if you have admin access to the build agent.

In the build steps, add a script step, and add the following inline script. This script will switch the node version for you. For first time running, you need to uncomment all the lines to install nvm first.

node -v
#curl -o- | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm
#nvm install 13.6.0
nvm use 13.6.0
nvm list
node -v

Then you can add a npm install step, it will use the new node version. Or you can simply add node install command to the script.

More about nvm, read this


您的电子邮箱地址不会被公开。 必填项已用*标注