in my program I have to work with a Node.js script. The script has to be executed. Itself writes some data into a data base and prints some data to stdout and some information to stderr. In order to start the script I use:
let child = Command::new(node)
.arg("my_script.js")
.stdout(Stdio::piped())
.stderr(Stdio::inherit())
.spawn()?;
The problem is that node doesn't seem to start. No data is writen into the data base nor do I receive bytes at child.stdout nor do I see some output on the console. However the node process is still running. If I launch normal binaries everythings works fine, so this seems to be related to node.js but I have no experience with it.
If it was failing to start, then it could be a case of node executable not being found (in terminal it uses PATH, but Command needs to have absolute path).
Does it work if you don't redirect stdout/stderr? I some programs I had a deadlock caused by child process waiting for its stdout buffer to be emptied by the parent process, but the parent process was waiting for the child to finish, so it wasn't reading it.
The problem was when passing in an emypty String it added an argument "" but node seams to interpret the first argument as the script and in my case I called $> node '' my_script.js so nothing was executed...