构建外壳为:
echo $PATH which node ls -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_6.10.2/bin node -v
结果是:
/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
为什么找不到node命令?
我正在使用docker官方jenkins映像运行它。
编辑:詹金斯:2.46.1-高山
根据问题JENKINS-34815(NodeJS插件无法安装全局NPM软件包)中的建议,检查您ldd -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_6.10.2/bin/node
ldd -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_6.10.2/bin/node
看到这个评论:
使用当前的docker jenkins:2.32.1-alpine和插件nodejs:1.0时,在使用节点7.4时会再次发生这种情况: 即使在PATH中找到了二进制文件并且该二进制文件是可执行文件,Alpine也无法运行该二进制文件:
+ /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
发生这种情况是因为图像不包含libstdc++.so.6nodejs所需的图像:
libstdc++.so.6
/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)
换句话说,node: not found并不意味着node未安装(它是可执行文件,可以在中找到$PATH)。 这意味着node找不到依赖项之一。
node: not found
node
$PATH