EN
Why Node.js prints "stdin is not a tty" error when I use stdin with pipe?
1 answers
2 points
I try to execure JavaScript source code sent via Node.js stdin.
Any idea, why when I execute:
xxxxxxxxxx
1
echo "console.log('Example text here...');" | node -
in Bash under Windows I get:
xxxxxxxxxx
1
stdin is not a tty
in Command Prompt (cmd.exe) under Windows stdout does not display anything?
1 answer
2 points
It looks like Node.js process doesn't have set up stdin/stdout, doesn't detect stdin/stdout or they were closed.
You can run echo "console.log('Example text here...');" | node -
different ways:
- by wrapping node command with bash command:
xxxxxxxxxx
1echo "console.log('Example text here...');" | bash -c "node -"
- by putting commands inside bash script:
e.g.script.sh
file:xxxxxxxxxx
12
3echo "console.log('Example text here...');" | node -
e.g. running
./script.sh
- by wrapping commands with bash command:
xxxxxxxxxx
1bash -c "echo \"console.log('Example text here...');\" | node -"
Maybe this snippet will be useful to also.
0 commentsShow commentsAdd comment