geowarin / boot-react

A starter application with spring boot and react
MIT License
591 stars 155 forks source link

Error after run ./gradlew bootRun - Caused by: java.io.IOException: Cannot run program "yarn" (in directory "frontend") #37

Closed andrespontt closed 7 years ago

andrespontt commented 7 years ago

I'm trying to run the project on OSX Sierra 10.12.6

Installed jdk8, maven, gradle and yarn with homebrew

Yarn command is available to be used on my terminal but it is throwing the following exception

Caused by: java.io.IOException: Cannot run program "yarn" (in directory "frontend"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) ~[na:1.8.0_144]

attached log after execute ./gradlew bootRun bootRun.log.txt

Maybe I missed some step before. Please help.

eungchang commented 7 years ago

same errors.

in my case not a "yarn" that is "cmd"

aused by: java.io.IOException: Cannot run program "cmd" (in directory "frontend"): error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) ~[na:1.8.0_144]

eungchang commented 7 years ago

the reason is Fix frontend relative path to run Yarn #36

eungchang commented 7 years ago

boot-react/backend/src/main/java/react/dev/YarnRunner.java

in the YarnRunner.java

private void yarnStart() throws IOException { ProcessExecutor process = new ProcessExecutor() .directory(new File("frontend"))
.command("yarn", "start") .redirectOutput(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asInfo()) .redirectError(Slf4jStream.of(LoggerFactory.getLogger("yarn")).asError());

if (isWindows()) {
  process = process.command("cmd", "/c", "yarn", "start");
}

process.start();

}

i changed like this .directory(new File("frontend"))
=> .directory(new File("../frontend"))

and then, IOException is solved