wedriverio jenkins - npm command not found error

user1207289 picture user1207289 · Nov 8, 2016 · Viewed 16.6k times · Source

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

Answer

user1207289 picture user1207289 · Dec 5, 2016

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