pino-pretty: `stdout is not a tty` on git bash on Windows

Hi, I tried to run the below command in git bash under Windows 11 and an error is shown as described below.

$ node http-fastify-complete.mjs | pino-pretty
stdout is not a tty

In fact the git bash is not a tty as desccribed below.

$ node -e 'console.log(tty.isatty())'
false

Is there any change to use pino-pretty in git bash?

Thanks

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (13 by maintainers)

Most upvoted comments

This https://docs.microsoft.com/en-us/windows/wsl/about

Windows is a video game OS for me 🤷‍♂️

I spent almost whole day on this. (windows 10, trying to use psql would return stdin is not tty) The only thing that worked for me was to reinstall git and choose Use Windows default console window

As it was suggested on this answer: https://stackoverflow.com/a/52264707/2357318

Ironically is in the same page along with the more popular answer about writing node.exe instead of node (I give that a try too. It wouldn’t throw the error but neither would it execute anything).

using node.exe -e ‘console.log(666)’ | pino-pretty works just fine sCxnpMT6 https://stackoverflow.com/a/62532536 @mcollina

According to the answers in the ☝️ SO thread:

Git bash is establishing some aliases in its <INSTALLDIR>/etc/profile.d/aliases.sh. This includes node which is tested for existing prior to declaring alias node=“winpty node.exe”. So, node is implicitly run through winpty while node.exe is not.

You can also see it in the actual aliases.sh file

Also git-bash has some issues link more or less to that

I also found that we can run either node or node.exe from winpty -Xallow-non-tty (an undocumented option ) as a workaround, e.g. :

$ winpty -Xallow-non-tty node.exe -e 'console.log(666)' | pino-pretty
666
$ winpty -Xallow-non-tty node -e 'console.log(666)' | pino-pretty
666

I’m considering making a small PR on git-bash (aka git-for-windows ) for adding -Xallow-non-tty to the winpty command in the aliases.sh to avoid this kind of trouble for all the aliased programs

using node.exe -e ‘console.log(666)’ | pino-pretty works just fine sCxnpMT6 https://stackoverflow.com/a/62532536 @mcollina