Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-53347

NPM cannot find node binary

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • nodejs-plugin
    • None
    • jenkinsci/blueocean:1.8.2
      jenkins:2.121.3
      org.jenkins-ci.plugins:nodejs:1.2.6

      1. Create a new Jenkins environment: 

      docker run --name jenkins -u root --rm -d -p 8080:8080 -v jenkins-data:/var/jenkins_home jenkinsci/blueocean:latest

      2. Add node-8.11.3 as a global tool named "node".

      3. Add the following pipeline:

      pipeline {
          agent any
          tools {
              nodejs 'node'
          }
          stages {
              stage('Example') {
                  steps {
                      sh 'npm --version'
                  }
              }
        }
      }
      

       4. Run it.

      The result:

      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] node
      Running on Jenkins in /var/jenkins_home/workspace/test
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Declarative: Tool Install)
      [Pipeline] tool
      [Pipeline] envVarsForTool
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Example)
      [Pipeline] tool
      [Pipeline] envVarsForTool
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] sh
      [test] Running shell script
      + npm --version
      env: ‘node’: No such file or directory
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 127
      Finished: FAILURE
      

      I see in the past this has happened due to an issue with the "env-inject" plugin, but that issue has been fixed, and I do not have that plugin installed.

            nfalco Nikolas Falco
            jonrimmer Jon Rimmer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: