If docker is available on the build server, use docker contained nodejs to build is a good idea too.
feng <fengnz@gmail.com> 于2020年1月17日周五 上午10:40写道:
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.[bash]node -v
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#nvm install 13.6.0
nvm use 13.6.0
nvm list
node -v[/bash]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 https://github.com/nvm-sh/nvm/blob/master/README.mdFeng
Feng
没有评论:
发表评论