To use different versions of node, it is very helpful to use nvm. Using nvm in a GitLab pipeline results in the following error:
While analysing the problem it was found that the issue being the environment variable defined in bashrc is not exported.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
To troubleshoot the issue created a script and sourced it before using the nvm:
~$ cat set_nvm.sh
#!/bin/bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
ssh remoteserver " source set_nvm.sh && nvm use 14.19.1"
It works!
New contributor
A V Rajesh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2