Jenkins NodeJS plugin: can't execute 'node'

4/10/2019

When using the NodeJS tool on a slave that is configured with a global package, the following error is given:

env: can't execute 'node': No such file or directory

If the build runs on an executor in master, there is no error and the package is installed as expected.

I am using the kubernetes plugin with jenkins/jnlp-slave:3.27-1 as the slave image.

Jenkins Version: 2.164.2
Kubernetes Plugin: 1.14.9
NodeJS Plugin: 1.2.9

Note: This is not a duplicate of Jenkins - env: ‘node’: No such file or directory as I am not using the alpine image as was the problem in that question.

-- Jacob Lambert
jenkins
jenkins-plugins
kubernetes-jenkins-plugin
node.js

1 Answer

12/20/2019

Same issue on my Jenkins.

The "download from nodejs.org" installer extracts the node package into a local directory.

It will then run "npm install -g" for each of the packages listed in the "Global npm packages to install" field in the NodeJS installer configuration ("Global tool configuration").

However, it does that before setting the system PATH to the directory where it extracted node, so npm will not find node.

I'm convinced that's a bug in the NodeJS Jenkins plugin. Your options are, as agusluc said, creating a custom jnlp-slave image (which is what I did), or file a bug with the developer of the plugin and hope it will be fixed.

-- ronin667
Source: StackOverflow