5

The build shell is:

echo $PATH
which node
ls -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_6.10.2/bin
node -v

The result is:

/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_6.10.2/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
/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_6.10.2/bin/node
-rwxrwxr-x 1 jenkins jenkins 30503659 Apr  4 09:01 node
lrwxrwxrwx 1 jenkins jenkins       38 Apr  9 13:09 npm -> ../lib/node_modules/npm/bin/npm-cli.js
/tmp/hudson8026342196338345661.sh: line 1: node: not found

Why cannot it find the node command?

I'm running it with docker the official jenkins image.

EDIT: jenkins:2.46.1-alpine

2 Answers 2

6

As suggested in issue JENKINS-34815 (NodeJS plugin unable to install global NPM packages), check you ldd -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_6.10.2/bin/node

See this comment:

With current docker jenkins:2.32.1-alpine and plugin nodejs:1.0 this happens again, when using node 7.4:
Alpine just can't run the binary even if it is found in PATH and is executable:

+ /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs7/bin/node -v

/var/jenkins_home/jobs/busx1/workspace@tmp/durable-a76d6fd5/script.sh: line 1: /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs7/bin/node: not found

This happens because the image doesn't contain libstdc++.so.6 as needed by nodejs:

    /lib64/ld-linux-x86-64.so.2 (0x55ae0ad53000)
    libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x55ae0ad53000)
    librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x55ae0ad53000)

Error loading shared library libstdc++.so.6: No such file or directory (needed by /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs7/bin/node)
    libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55ae0ad53000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f0ac773e000)
    libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x55ae0ad53000)
    libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55ae0ad53000)

In other words, node: not found does not mean node is not installed (it is, it is executable and found in the $PATH).
It means one of node dependencies is not found.

8
  • Should I not using alpine or install libstdc++.so.6 myself?
    – hbrls
    Commented Apr 9, 2017 at 15:55
  • @hbrls The jenkins image is based on alpine already. All I am saying is that your image might be missing some elements. An ldd -l should tell you which one. If you see them missing, you will need to build your own image based on your existing image jenkins:2.46.1-alpine, to add the missing element.
    – VonC
    Commented Apr 9, 2017 at 17:26
  • So whats the solution here ? How to fix the "node not found" issue in alpine ? I'm using Jenkins ver. 2.176.1 alpine and I have the same issue. Commented Feb 18, 2020 at 9:33
  • @JeraldSabuM I don't fully remember, but I suspect adding the missing dependency(ies) would be enough
    – VonC
    Commented Feb 18, 2020 at 9:36
  • @VonC How do i know, what dependency to install? (ldd -l gives error) :::--- 11:56:21 + ldd -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node 11:56:21 ldd: cannot load -l: No such file or directory Commented Feb 18, 2020 at 10:57
1

I run the Jenkins by a docker image jenkins:2.60.3-alpine.

And I've solved this by entering the container then install node directly:

You can find your container name using:

$ docker container ls

then replace with with the real name of container,

$ docker exec -u 0 -it <container_name> bash

bash-4.3# apk add --no-cache nodejs
bash-4.3# node --version
v6.9.5
bash-4.3# npm --version
5.6.0

Finally, the job could use the node and npm both.

2
  • This does not answer the question. The problem here is with alpine and Jenkins nodejs plugin. There's no issue in installing nodejs directly in alpine docker. Commented Feb 18, 2020 at 10:54
  • apk-get for alpine version dockers, but ubuntu based you should use apt-get for debian bases.
    – uzay95
    Commented Mar 8, 2020 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.