Bluemix build pipeline set node and npm version

旧巷老猫 提交于 2019-12-02 01:52:01

Ok, bluemix just provide a few versions of node and npm... Found the solution at http://gh-blog.mybluemix.net/blogs/cokeSchlumpf/rethink-it/posts/bluemix/node-buildpipeline.md?cm_mc_uid=01575932457714863658655&cm_mc_sid_50200000=1487233177

#!/bin/bash
export NVM_DIR=/home/pipeline/nvm
export NODE_VERSION=5.10.1
export NVM_VERSION=0.29.0

npm config delete prefix \
  && curl https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | sh \
  && . $NVM_DIR/nvm.sh \
  && nvm install $NODE_VERSION \
  && nvm alias default $NODE_VERSION \
  && nvm use default \
  && node -v \
  && npm -v

npm install
# Further steps ...

The answer above pointed me in the right direction, but newer versions of NVM wouldn't work. NVM's install.sh now checks if NVM_DIR is set but the directory doesn't exist.

I changed the NVM_DIR path and declared it after install.sh has completed.

bash
#!/bin/bash

export NODE_VERSION=8
export NVM_VERSION=0.33.11

npm config delete prefix \
  && curl -o- https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash \
  && export NVM_DIR="$HOME/.nvm" \
  && . $NVM_DIR/nvm.sh \
  && nvm install $NODE_VERSION \
  && nvm alias default $NODE_VERSION \
  && nvm use default \
  && node -v \
  && npm -v
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!