Search code examples
node.jsjenkinsjenkins-plugins

Jenkins unable to run npm command on slave, though slave has nodejs installed


I have to run npm install on the jenkins slave once it clones the git repo. But jenkins is giving some weird error, I am unable to understand.

enter image description here

Nodejs is installed on my windows slave. It is also there in the path. On jenkins I have the nodejs plugin installed. I also have below option checked in the job. Can anyone please help me with what is wrong here.

enter image description here


Solution

  • The "Provide Node & npm bin/ folder to the PATH" is to offer a Nodejs from master to slave, this requires

    1. prepare Nodejs Installation on master
    2. enter 'Manage Jenkins' with Jenkins admin to config the Installation then

    Then in your job configuration you can choose the pre-configured installation from the dropdown list.

    If you have pre-installed Nodejs on slave and node binary in PATH, you no need to rely on "Provide Node & npm bin/ folder to the PATH", just execute node cmd directly.

    FYI, config node binary in system environment PATH, in case Jenkins job run as another user, but the user has node binary in PATH.