昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期五, 一月 17, 2020

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

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.

--
Feng


--
Feng

没有评论:

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.