Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle couldn't execute npm command

I'm trying to run a npm command inside of gradle task but I'm getting a strange error:

Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
    at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
    at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
    at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
    ... 2 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/psilva/Documents/projects/registrolivre"): error=2, No such file or directory
    at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
    ... 4 more
Caused by: java.io.IOException: error=2, No such file or directory

And this is my task:

task npmInstall(type: Exec) {
    commandLine "npm", "install"
}

Could someone help?

like image 822
Pedro Henrique Avatar asked Feb 21 '16 18:02

Pedro Henrique


1 Answers

If you are on Windows try this:

task npmInstall(type: Exec) {
    commandLine "npm.cmd", "install"
}

instead of this:

task npmInstall(type: Exec) {
    commandLine "npm", "install"
}
like image 79
Vikash Madhow Avatar answered Sep 24 '22 10:09

Vikash Madhow