When no TTY if the event loop becomes empty node exits with code 0
Author: tjenkinsonCreated Sep 11, 2025Updated Sep 11, 2025
hey
If you run:
import enquirer from 'enquirer'
async function go() {
const res = await enquirer.prompt({
type: 'confirm',
name: 'question',
message: 'Message',
initial: true,
})
console.log('got', res)
}
go().catch(e => {
console.error(e)
})with no TTY
e.g. node test.mjs < /dev/null && echo 'oops'
Node quits and you'll see 'oops'
I think if there's no tty we should throw an exception? Or maybe if there's an initial just pretend the user chose that? That feels more dangerous though.
This is causing unexpected exits in pnpm. See https://github.com/pnpm/pnpm/pull/9960 and https://github.com/pnpm/pnpm/issues/9744
Happy to prepare a PR
Source: enquirer/enquirer