Vinay Verma
Vinay Verma

Reputation: 593

NPM Issue while running from jenkins

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 
':npmInstall'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)

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

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

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.

Upvotes: 1

Views: 2016

Answers (1)

Vinay Verma
Vinay Verma

Reputation: 593

My issue was resolved on the Gradle help forum. The solution is to download Node.js during the build by adding this to build.gradle:

node {
    download = true
    version='9.2.0'
}

Upvotes: 1

Related Questions