Run npm and npm installed apps in console via ScriptRunnerUtil on Windows OS

已回答

Hello,

 

I'm trying to run a console command from the plugin via ScriptRunnerUtil class. This command (application) was installed via npm. For this, I'm using similar code

 

val generalCommandLine = new GeneralCommandLine(commands)

generalCommandLine.setCharset(Charset.forName("UTF-8"))
generalCommandLine.setWorkDirectory(workDirectory)

ScriptRunnerUtil.getProcessOutput(generalCommandLine, ScriptRunnerUtil.STDOUT_OUTPUT_KEY_FILTER, 120000)

 

This code works great on macOS and Linux but failed on Windows. On Windows OS it can't see installed application and npm. 

 

For Windows OS ScriptRunnerUtil class returns error: "Cannot run program "snyk" (in directory "C:\code\test-app"): CreateProcess error=2, The system cannot find the file specified".

 

Maybe someone knows the solution?

 

Best regards,

Alex.

0

It looks like an issue with the Windows configuration itself - npm binaries location is not present in the PATH variable, so they cannot be properly resolved.

0

Hello Jakub,

 

Thank you for the response! It seems so. I tried to run this command directly in the Windows terminal and it's ok, it's working. Also, I tried to run this command in the IntelliJ Terminal window and it also works fine. Maybe I can use some other approach from IntelliJ API to run a console command in the background?

 

Regards,

Alex.

0

请先登录再写评论。