I'm trying to create a window that can receive input (messages) from stdin, but when I use process.stdin (or process.openStdin()) I receive the following error:
Error: Implement me. Unknown stdin file type!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Ran into this.
Ran into this as well.
Is it even possible to聽make such聽a聽feature so聽that it聽works across聽platforms? It聽has always seemed to聽me that a聽GUI聽window cannot receive anything from聽stdin on聽Windows.
+1
+1
+1
I have written a module that wraps the process object replacing the standard streams with tcp streams so you can use them. nw-wrap
Was there any resolution for this?
+1. I may be encountering this. I don't get that original error, but process.stdin doesn't seem to receive stdin. For example, when running:
echo 'Hello' | nw .
...stdin just gets an end event. Sample reading code that just outputs EOF:
const { stdin, stdout } = process;
stdin.resume();
stdin.setEncoding('utf8');
stdin
.on('data', str => {
stdout.write('Got ' + str);
})
.on('end', () => {
stdout.write('EOF');
});
+1
+1
+1
+1
Any word from the team on this? It's been open for a long time.
We can try to bypass using https://www.npmjs.com/package/nwjs-j5-fix
We can try to bypass using https://www.npmjs.com/package/nwjs-j5-fix
I created that package but I really wish I could stop using it. Can we hope for this issue to be bumped up the priority list anytime soon @rogerwang ?
Can reproduce this issue on nwjs v0.26.6.
Can reproduce on 0.27.1 on Mac, and what's worse, @cotejp's fix does not appear to work so there aren't any viable options I can find without looking at other methods for communicating with the app.
and what's worse, @cotejp's fix does not appear to work
Your use case might be different from mine, but my little fix (nwjs-j5-fix) is still working for me in version 0.27.1.
Your use case might be different from mine, but my little fix (nwjs-j5-fix) is still working for me in version 0.27.1.
Ah interesting. Well I'm glad to know that it should still be working. Would you mind posting a small snippet showing the most minimal amount of code necessary to test the fix? Do you use the readline module? What I've been trying, just to see if I can get any input at all:
nw.require('nwjs-j5-fix').fix();
var readline = nw.require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function (line) {
alert(line);
});
My use case is I'm launching nwjs from an Adobe AIR project (probably not a typical use case, but alas...), as a NativeProcess, and am writing to the process's stdin like so:
process.standardInput.writeUTF("hello")
But haven't been able to get any indication that the input as received. I can retrieve the stdout from this process just fine. Immediately after launching the process, I do get a "standard error data" event but am not sure what exactly is triggering that.
I've also attempted launching it from another node app using child_process.spawn, but that doesn't seem to work for me either.
The nwjs-j5-fix module fixes the issue of NW.js and Johnny-Five not being able to communicate. It does that successfully so I have not tested it under other scenarios.
You can look at the source code if you wnat to know more. As you'll see, it is very simple. I did not even bother with stdout because it is not needed in my scenario.
Cheers!
@rogerwang Is there any hope of progress on this for macOS? I have a product that would benefit hugely from having this fixed, it's the only thing keeping me from switching to nw.js
@derrickb yes, will look into it. I believe the issue is mostly for Windows.
@rogerwang thanks Roger! I've done extensive testing and unfortunately experienced the issue on Mac as well... tested with several nw.js versions last year, and again earlier this year.
Appears related: #3299
This also happens on macos at least, so https://github.com/djipco/nwjs-j5-fix is still required :-/
Is it a won't-fix @rogerwang ?
This also happens on macos at least, so https://github.com/djipco/nwjs-j5-fix is still required :-/
Is it a won't-fix @rogerwang ?
When I tried nwjs-j5-fix on macOS, I still couldn't get stdin working. Were you able to?
@derrickb I'm using it on macOS Mojave with no issues.
Most helpful comment
+1
Any word from the team on this? It's been open for a long time.