Using nvm in build shell script causes 'No such file or directory' error

14 views
Skip to first unread message

Martin Baillie

unread,
Jun 15, 2020, 12:45:07 PM6/15/20
to Jenkins Users
Hi,

I'm using Jenkins to build a Cordova project. 

Recently I've upgraded the Jenkins server (a MacMini running Mojave) from a standard node install to use NVM.

I'd like to call nvm from within the build script I call from Jenkins' Build > Execute Shell option.

However when I reference nvm from within the script (see below examples) I get the error 'No such file or directory'.

nvm use

or

. ~/.nvm/nvm.sh

nvm
use

or

source /path/to/.nvm/nvm.sh

nvm
use

I can run the script directly from the server's terminal with no error, NVM is sourced within ~/.profile, .profile is sourced within ~/.bashrc and .bashrc is sourced within ~/.bash_profile.

I am aware of the NVMWrapper plugin, but am avoiding that for the time being due to not being certain it will work with my current version of Jenkins and I'd rather not break Jenkins as our resident Jenkins expert is currently unavailable.







Reply all
Reply to author
Forward
0 new messages