NVM (Node Version Manager) is a tool that allows you to manage multiple versions of Node.js on the same machine. It is possible that NVM is not working on Jenkins execute shell due to several reasons. Here are some troubleshooting steps that you can try:
Make sure that NVM is installed on the Jenkins agent or node where the build is running. You can install NVM using the following command:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh | bash
Check that the correct version of Node.js is installed using NVM. You can use the following command to install a specific version of Node.js:
nvm install <version>
Set the Node.js version to use in the shell script. You can use the following command to set the Node.js version to use:
nvm use <version>
Make sure that the NVM environment variables are set correctly in the Jenkins environment. You can use the following command to set the NVM environment variables:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Ensure that the Jenkins user has the correct permissions to access NVM and the Node.js binaries. You can set the permissions using the following commands:
sudo chown -R jenkins:jenkins /home/jenkins/.nvm
sudo chmod -R 777 /home/jenkins/.nvm
Comments (0)