Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wedriverio jenkins - npm command not found error

I am trying to run webdriverio test from jenkins and following this . I installed nodeJS plugin for jenkins and under global tool config, for NodeJS , added a name and installation directory as /usr/local/bin (node executable is in this folder)

In Jenkins, in project config , under build environment, I have checked

Provide Node & npm bin/ folder to PATH and chosen the node installation name from previous step

But when I am trying to run npm install npm test ,by adding these commands under execute shell under Build and building it, I receive this error

Building in workspace /Users/Shared/Jenkins/Home/workspace/wdio-project
[wdio-project] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson1478028169114509075.sh
+ npm install
/Users/Shared/Jenkins/tmp/hudson1478028169114509075.sh: line 2: npm: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
like image 424
user1207289 Avatar asked Nov 08 '16 20:11

user1207289


2 Answers

In case someone is looking for same issue, I resolved the above error by adding export PATH=/usr/local/bin to the execute shell under build. This post helped me

like image 177
user1207289 Avatar answered Sep 19 '22 22:09

user1207289


There is currently a bug opened about this (JENKINS-26583 and JENKINS-27170)

I could workaround this bug by adding explicitly node on the PATH by adding this line :

export PATH=$PATH:/home/jenkins/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_js/bin/
like image 20
Rexave Avatar answered Sep 19 '22 22:09

Rexave