Languages

Why Node.js prints "stdin is not a tty" error when I use stdin with pipe?

2 points
Asked by:
troya
692

I try to execure JavaScript source code sent via Node.js stdin.

Any idea, why when I execute:

in Bash under Windows I get:

in Command Prompt (cmd.exe) under Windows stdout does not display anything?

1 answer
2 points
Answered by:
Root-ssh
178180

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:

  1. by wrapping node command with bash command:

     

  2. by putting commands inside bash script:
    e.g. script.sh file:

    e.g. running ./script.sh
     

  3. by wrapping commands with bash command:

 

Maybe this snippet will be useful to also.

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join