Build step fails when using exact syntax as the NodeJS plugin wiki page at https://plugins.jenkins.io/nodejs

      tools {
       nodejs 'name'
       }
      

      sh 'npm install' is called the output from Jenkins the result is:

       + npm install 
       env: 'node': No such file or directory 
       script returned exit code 127
      

      Docker exec on npm produces the exact same error:

       /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node/bin/npm
       env: 'node': No such file or directory
      

          [JENKINS-43593] NPM unable to locate node binary

          Nikolas Falco added a comment -

          This sound like duplicate of one of these JENKINS-27170 JENKINS-41762 JENKINS-42323 JENKINS-41857 JENKINS-43066 JENKINS-43156

          Do you have EnvInject plugin installed?
          If yes than you fall in JENKINS-26583

          The workaround reported in our wiki page is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          Nikolas Falco added a comment - This sound like duplicate of one of these JENKINS-27170 JENKINS-41762 JENKINS-42323 JENKINS-41857 JENKINS-43066 JENKINS-43156 Do you have EnvInject plugin installed? If yes than you fall in JENKINS-26583 The workaround reported in our wiki page is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          Dan Woytowich added a comment -

          Ok thanks, I have removed the EnvInject plugin

          Dan Woytowich added a comment - Ok thanks, I have removed the EnvInject plugin

          Dan Woytowich added a comment -

          I have re-provisioned a fresh installation without envinject and there is still an error. I do not believe this should not have been closed as I am experiencing the exact same node error.

          Error: 
          Running shell script
          + npm install
          env: ‘node’: No such file or directory
          script returned exit code 127

          *********************************************************************************
          JENKINSFILE

          pipeline {
          agent any
          tools {
          nodejs 'node7'
          }
          stages {
          stage('Example') {
          steps {
          echo "Branch is ${env.BRANCH_NAME}"
          sh 'npm install'
          sh 'npm --version'
          echo "about to build!"
          sh 'npm build'
          }
          }
          }
          }
          ***********************************************************************************

          Dan Woytowich added a comment - I have re-provisioned a fresh installation without envinject and there is still an error. I do not believe this should not have been closed as I am experiencing the exact same node error. Error:  Running shell script + npm install env: ‘node’: No such file or directory script returned exit code 127 ********************************************************************************* JENKINSFILE pipeline { agent any tools { nodejs 'node7' } stages { stage('Example') { steps { echo "Branch is ${env.BRANCH_NAME}" sh 'npm install' sh 'npm --version' echo "about to build!" sh 'npm build' } } } } ***********************************************************************************

          Nikolas Falco added a comment -

          I just try and wroks.

          1. Download jenkins war 2.46.1
          2. java -jar jenkins.war
          3. browse http://localhost:8080
          4. Manage Jenkins -> Manage Plugins -> Available
          5. select only NodeJS (no update other plugin to avoid someone download envinject)
          6. restart jenkins
          7. create a test pipeline job
          8. use follow DSL
            pipeline {
                agent any
                tools {
                    nodejs 'node 7'
                }
                stages {
                    stage('Example') {
                        steps {
                            bat 'npm --version'
                        }
                    }
                }
            }
            

          this is the output

          Started by user anonymous
          [Pipeline] node
          Running on master in C:\Users\Nikolas Falco\.jenkins\workspace\test2
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Declarative: Tool Install)
          [Pipeline] tool
          Unpacking https://nodejs.org/dist/v7.9.0/node-v7.9.0-win-x64.zip to C:\Users\Nikolas Falco\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\node_7 on Jenkins
          [Pipeline] envVarsForTool
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] withEnv
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Example)
          [Pipeline] bat
          [test2] Running batch script
          
          C:\Users\Nikolas Falco\.jenkins\workspace\test2>npm --version 
          4.2.0
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // withEnv
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          

          Nikolas Falco added a comment - I just try and wroks. Download jenkins war 2.46.1 java -jar jenkins.war browse http://localhost:8080 Manage Jenkins -> Manage Plugins -> Available select only NodeJS (no update other plugin to avoid someone download envinject) restart jenkins create a test pipeline job use follow DSL pipeline { agent any tools { nodejs 'node 7' } stages { stage('Example') { steps { bat 'npm --version' } } } } this is the output Started by user anonymous [Pipeline] node Running on master in C:\Users\Nikolas Falco\.jenkins\workspace\test2 [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Tool Install) [Pipeline] tool Unpacking https://nodejs.org/dist/v7.9.0/node-v7.9.0-win-x64.zip to C:\Users\Nikolas Falco\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\node_7 on Jenkins [Pipeline] envVarsForTool [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Example) [Pipeline] bat [test2] Running batch script C:\Users\Nikolas Falco\.jenkins\workspace\test2>npm --version 4.2.0 [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS

          Dan Woytowich added a comment -

          Well this is a problem still with the official Jenkins/BlueOcean Image in DockerHub

          Dan Woytowich added a comment - Well this is a problem still with the official Jenkins/BlueOcean Image in DockerHub

          Nikolas Falco added a comment -

          With jenkins pipeline you can easly do a workaround, try the follow

          env.NODEJS_HOME = "${tool node7}"
          env.PATH="${env.NODEJS_HOME}:${env.PATH}"
          echo ${env.PATH}
          sh 'node -version'
          

          Nikolas Falco added a comment - With jenkins pipeline you can easly do a workaround, try the follow env.NODEJS_HOME = "${tool node7}" env.PATH= "${env.NODEJS_HOME}:${env.PATH}" echo ${env.PATH} sh 'node -version'

          Marc Smith added a comment -

          Since this is still a problem in the official Jenkins/BlueOcean can we reopen this? this is a critical bug for anyone using npm.

          Marc Smith added a comment - Since this is still a problem in the official Jenkins/BlueOcean can we reopen this? this is a critical bug for anyone using npm.

          Marc Smith added a comment - - edited

          Hi Nikolas,

          This is not fixed in the jenkinsci/blueocean image on docker hub. Your instructions to reproduce require downloading a .war file and running directly from java. This defeats the purpose of having the jenkinsci/blueocean image on docker.   Please reproduce/fix the issue using the official jenkinsci/blueocean on an Ubuntu 16.04 LTS machine. Thank you!

          Marc Smith added a comment - - edited Hi Nikolas, This is not fixed in the jenkinsci/blueocean image on docker hub. Your instructions to reproduce require downloading a .war file and running directly from java. This defeats the purpose of having the jenkinsci/blueocean image on docker.   Please reproduce/fix the issue using the official jenkinsci/blueocean on an Ubuntu 16.04 LTS machine. Thank you!

          Nikolas Falco added a comment - - edited

          Hi the docker image is out the scope of the plugin and with other maintainers.
          I had a look on the docker image (it is not a Ubuntu but an alpine image JAVA_ALPINE_VERSION='8.181.13-r0').

          • the PATH environment variable is correctly setup PATH='/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin'
          • the node is download and place in the correct folder and the bin folder have the execute (+x) attribute setup correctly

          anyway the node command does not work, not only in jenkins but also if you run the node command from a shell it give the same error.

          I had a look around and seems the alpine image have a limited symbolic library needed by nodejs. The official nodejs image does not use the distribution archive but compile in place the source code. This could not be done by the plugin

          Nikolas Falco added a comment - - edited Hi the docker image is out the scope of the plugin and with other maintainers. I had a look on the docker image (it is not a Ubuntu but an alpine image JAVA_ALPINE_VERSION='8.181.13-r0' ). the PATH environment variable is correctly setup PATH='/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin' the node is download and place in the correct folder and the bin folder have the execute (+x) attribute setup correctly anyway the node command does not work, not only in jenkins but also if you run the node command from a shell it give the same error. I had a look around and seems the alpine image have a limited symbolic library needed by nodejs . The official nodejs image does not use the distribution archive but compile in place the source code . This could not be done by the plugin

          I had this error too when creating a pipeline using nodejs. Maybe the tutorials should be updated if the `jenkins/blueocean` image have these problems. https://jenkins.io/doc/book/blueocean/getting-started/#as-part-of-jenkins-in-docker

          António Carvalho added a comment - I had this error too when creating a pipeline using nodejs. Maybe the tutorials should be updated if the `jenkins/blueocean` image have these problems.  https://jenkins.io/doc/book/blueocean/getting-started/#as-part-of-jenkins-in-docker

            nfalco Nikolas Falco
            whytoe Dan Woytowich
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: