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

"Provide Node & npm bin/ folder to PATH" not working for "npm install"

      I followed the plugin doc that checked "Provide Node & npm bin/ folder to PATH", but it not works for npm install. You can see my screenshots.

      The execute shell command can works very well, but the console log shows "node: command not found", maybe not export the "$PATH"?

      $ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/bin/npm install -g karma karma-cli karma-jasmine karma-junit-reporter karma-phantomjs-launcher karma-spec-reporter gulp gulp-concat gulp-sass gulp-minify-css gulp-rename
      npm WARN engine karma-cli@0.0.4: wanted: {"node":"~0.8 || ~0.10"} (current: {"node":"0.12.0","npm":"2.5.1"})
      npm WARN engine karma@0.12.31: wanted: {"node":"~0.8 || ~0.10"} (current: {"node":"0.12.0","npm":"2.5.1"})
      /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/bin/karma -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/lib/node_modules/karma-cli/bin/karma
      npm WARN optional dep failed, continuing fsevents@0.3.5
      
      > phantomjs@1.9.15 install /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/lib/node_modules/karma-phantomjs-launcher/node_modules/phantomjs
      > node install.js
      
      sh: node: Command not found
      
      > ws@0.4.32 install /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
      > (node-gyp rebuild 2> builderror.log) || (exit 0)
      
      /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/bin/gulp -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/lib/node_modules/gulp/bin/gulp.js
      
      > node-sass@2.0.1 install /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/lib/node_modules/gulp-sass/node_modules/node-sass
      > node scripts/install.js
      
      sh: node: Command not found
      npm ERR! Linux 3.16.0-31-generic
      npm ERR! argv "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/bin/node" "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/bin/npm" "install" "-g" "karma" "karma-cli" "karma-jasmine" "karma-junit-reporter" "karma-phantomjs-launcher" "karma-spec-reporter" "gulp" "gulp-concat" "gulp-sass" "gulp-minify-css" "gulp-rename"
      npm ERR! node v0.12.0
      npm ERR! npm  v2.5.1
      npm ERR! code ELIFECYCLE
      
      npm ERR! phantomjs@1.9.15 install: `node install.js`
      npm ERR! Exit status 127
      npm ERR! 
      npm ERR! Failed at the phantomjs@1.9.15 install script 'node install.js'.
      npm ERR! This is most likely a problem with the phantomjs package,
      npm ERR! not with npm itself.
      npm ERR! Tell the author that this fails on your system:
      npm ERR!     node install.js
      npm ERR! You can get their info via:
      npm ERR!     npm owner ls phantomjs
      npm ERR! There is likely additional logging output above.
      npm ERR! Linux 3.16.0-31-generic
      npm ERR! argv "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/bin/node" "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs-0.12.0/bin/npm" "install" "-g" "karma" "karma-cli" "karma-jasmine" "karma-junit-reporter" "karma-phantomjs-launcher" "karma-spec-reporter" "gulp" "gulp-concat" "gulp-sass" "gulp-minify-css" "gulp-rename"
      npm ERR! node v0.12.0
      npm ERR! npm  v2.5.1
      
      npm ERR! Uncaught, unspecified "error" event.
      npm ERR! 
      npm ERR! If you need help, you may report this error at:
      npm ERR!     <http://github.com/npm/npm/issues>
      
      npm ERR! Please include the following file with any support request:
      npm ERR!     /npm-debug.log
      

          [JENKINS-27170] "Provide Node & npm bin/ folder to PATH" not working for "npm install"

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstaller.java
          http://jenkins-ci.org/commit/nodejs-plugin/9a44fe8e046e6aaf85f5abcd45e006780c460dd5
          Log:
          [FIXED JENKINS-27170] add node to PATH while running npm

          1. Conflicts:
          2. src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstallation.java

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstaller.java http://jenkins-ci.org/commit/nodejs-plugin/9a44fe8e046e6aaf85f5abcd45e006780c460dd5 Log: [FIXED JENKINS-27170] add node to PATH while running npm Conflicts: src/main/java/jenkins/plugins/nodejs/tools/NodeJSInstallation.java

          Nikolas Falco added a comment -

          This issue was resolved by ndeloof in the commit https://github.com/jenkinsci/nodejs-plugin/commit/f38e0a5d20a747d235dd1c439ebb92eef4b0fe8f
          I've try without any local system nodejs package and I have same issue. With local system nodejs package (nodejs >=6) I get the JENKINS-33698 behaviour.

          Nikolas Falco added a comment - This issue was resolved by ndeloof in the commit https://github.com/jenkinsci/nodejs-plugin/commit/f38e0a5d20a747d235dd1c439ebb92eef4b0fe8f I've try without any local system nodejs package and I have same issue. With local system nodejs package (nodejs >=6) I get the JENKINS-33698 behaviour.

          Hello,

          It seems this issue is back with plugin's version 1.0, but apparently just on master node :
          Jenkins ver. 2.32.1 & Jenkins ver. 2.19.1

          I check "Provide Node & npm bin/ folder to PATH", an echo of $PATH shows only the system's and user's bins, and the build hangs with "npm not found" in console log.

          I've try same build on the same machine but configured as slave, the echo $PATH show the value expected with the NodeJS bin path.

          The same build with the 0.2.2 plugin version works fine.

          Christophe FERAUD added a comment - Hello, It seems this issue is back with plugin's version 1.0, but apparently just on master node : Jenkins ver. 2.32.1 & Jenkins ver. 2.19.1 I check "Provide Node & npm bin/ folder to PATH", an echo of $PATH shows only the system's and user's bins, and the build hangs with "npm not found" in console log. I've try same build on the same machine but configured as slave, the echo $PATH show the value expected with the NodeJS bin path. The same build with the 0.2.2 plugin version works fine.

          Nikolas Falco added a comment - - edited

          Do you have EnvInject plugin installed?
          If yes than also you have fall in JENKINS-26583

          The 0.2.2 use a different way (and old) to inject node js in PATH variable that cause similar problem to other plugins.

          Workaround is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          Nikolas Falco added a comment - - edited Do you have EnvInject plugin installed? If yes than also you have fall in JENKINS-26583 The 0.2.2 use a different way (and old) to inject node js in PATH variable that cause similar problem to other plugins. Workaround is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          It's definitively a EnvInject plugin issue -> JENKINS-26583.

          The nodejs plugin works as expected if I check the EnvInject check box even if I do not have variables to inject.

          Thank for your reply.

          Christophe FERAUD added a comment - It's definitively a EnvInject plugin issue -> JENKINS-26583 . The nodejs plugin works as expected if I check the EnvInject check box even if I do not have variables to inject. Thank for your reply.

          Nikolas Falco added a comment -

          Thank you

          Nikolas Falco added a comment - Thank you

          Lars Velle added a comment -

          This issues seems to have reappeared.

          With Environment Injector Plugin installed the system version of node/npm is used, and not custom NodeJS Installations from "Provide Node & npm bin/ folder to PATH"

          Jenkins version 2.44
          Issues with both Environment Injector Plugin 1.93.1 and 1.92.1.

          Disabling Environment Injector Plugin makes the problem go away.

          Lars Velle added a comment - This issues seems to have reappeared. With Environment Injector Plugin installed the system version of node/npm is used, and not custom NodeJS Installations from "Provide Node & npm bin/ folder to PATH" Jenkins version 2.44 Issues with both Environment Injector Plugin 1.93.1 and 1.92.1. Disabling Environment Injector Plugin makes the problem go away.

          Daniel Wilmer added a comment -

          Since we also have the same issue, I will reopen this issue instead of creating a new one.

          Daniel Wilmer added a comment - Since we also have the same issue, I will reopen this issue instead of creating a new one.

          Nikolas Falco added a comment -

          Do you have EnvInject plugin installed?
          If yes than also you have fall in
          JENKINS-26583
          The 0.2.2 use a different way (and old) to inject node js in PATH variable that cause similar problem to other plugins.
          Workaround is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          Nikolas Falco added a comment - Do you have EnvInject plugin installed? If yes than also you have fall in JENKINS-26583 The 0.2.2 use a different way (and old) to inject node js in PATH variable that cause similar problem to other plugins. Workaround is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          Daniel Wilmer added a comment -

          Yes, I have EnvInject installed. So I will stay on 0.2.2 until JENKINS-26583 is fixed.

          Daniel Wilmer added a comment - Yes, I have EnvInject installed. So I will stay on 0.2.2 until JENKINS-26583 is fixed.

            nfalco Nikolas Falco
            abcfy2 feng yu
            Votes:
            3 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated:
              Resolved: