NPM Issue while running from jenkins

(Vinay Verma) #1

I am currently facing some issue which are related to gradle/NodeJS. What I did is used Node plugin by writing this in my gradle script:

apply plugin: 'com.moowork.node'

dependencies {
	classpath 'com.moowork.gradle:gradle-node-plugin:0.12'

now when I try to run install npm command from terminal(CentOS) by running:

gradle npmInstall

it is running perfectly fine and installing all the required packages whereas when I run the same command from Jenkins (Jenkins installed in centos), I am getting following error msg:

:npmInstall FAILED
 FAILURE: Build failed with an exception.

* What went wrong:
  Execution failed for task ':npmInstall'.
  > A problem occurred starting process 'command 'npm''

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task 
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(

Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'npm''
at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(

Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(

Can somebody please help me with is. I am not getting what Wrong I am doing.
I am also getting the same error msg if try to run following command:

gradle npm_run_build_prod 

whereas the same list of commands are working for my local windows jenkins.

(James Justinic) #2

You can receive that error if the npm command is not available on the PATH. The user running Jenkins on CentOS might have a reduced path. By default, the plugin will not download NodeJS/NPM unless you add:

node {
    download = true

Otherwise, it is expected that Node is installed and npm is available on the path.

(Vinay Verma) #3

Thanks James!

Your suggestion resolved my issue I just additionally mentioned the version like this:

node {
    download = true

and it worked.
Thanks Again :slight_smile: