Theo
Theo

Reputation: 2042

Jenkins - env: ‘node’: No such file or directory

I have a jenkins server that is configured using https://github.com/shierro/jenkins-docker-examples/tree/master/05-aws-ecs

I am running a blue ocean pipeline using a simple Jenkinsfile and the jenkins NodeJS plugin

pipeline { 
  agent any 

  tools {
    nodejs 'node10'
  }

  stages {
    stage ('Checkout Code') {
      steps {
        checkout scm
      }
    }
    stage ('Install dependencies') {
      steps {
        sh "echo $PATH"
        sh "npm install"
      }
    }
  }
}

I made sure to add the node10 global tool as well w/c is used above enter image description here

When the pipeline gets to the script sh "npm install" i am running through this error enter image description here

this is the output of the command echo $PATH enter image description here

so i think it's not a path issue

Also, it also wasn't able to add the global package enter image description here

More info that might help:

Any ideas why the jenkins server does not know where node is?

Big thanks in advance!

Upvotes: 10

Views: 9561

Answers (5)

madhu131313
madhu131313

Reputation: 7386

I want to highlight Mitch Downey's comment, it can't be just a comment because after spending 4 hours with no solution this comment helped me to resolve the solution

My issue ended up being with the jenkinsci/blueocean image. I was able to just replace that image with jenkins/jenkins:lts and the NodeJS plugin began working as expected

Upvotes: 0

Shashikant Sharma
Shashikant Sharma

Reputation: 556

Make a symbolic link like this:

sudo ln -s /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node/bin/node /usr/bin/node

Upvotes: 0

Devops Anil
Devops Anil

Reputation: 11

I have faced the same issue with jenkinsci/blueocean. No jenkins nodejs plugin needed.

pipeline { 
  agent any 

  stages {
    stage ('Checkout Code') {
      steps {
        checkout scm
      }
    }
    stage ('Install dependencies') {
      steps {
        sh "apk add nodejs"
        sh "echo $PATH"
        sh "npm install"
      }
    }
  }
}

Upvotes: 1

Jay Reddy
Jay Reddy

Reputation: 700

I have faced the same issue with jenkinsci/blueocean. I have resolved this by installing nodejs with below command(inside docker) not as jenkins plugin

apk add nodejs

Upvotes: 2

Theo
Theo

Reputation: 2042

Thanks to @JoergS for some insight! The culprit in this case is: using alpine image as the docker base. So switching from jenkins/jenkins:2.131-alpine to jenkins/jenkins:2.131 solved the NodeJS plugin issue.

Upvotes: 9

Related Questions