Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
Node.js on Ubuntu: Chilld process with piped stdio, does not emit stdout and stderr

I have a fresh installation of Ubuntu 20.04.2 (run in a virtual machine on mac).

I've installed Node.js v16 (via official software channel) and observed an extremely weird issue. Child processes spawned with studio: 'pipe' do not emit any stdout or stderr data.

Steps to reproduce:

child.js

console.log("Some text");

const interval = setInterval(() => {
    console.log("Other text")
}, 100)

setTimeout(() => clearInterval(interval), 1000);

main.js

const childProcess = require('child_process');

const child = childProcess.spawn('node', ['child.js'], { stdio: 'pipe'});

if (child.stdout) {
    console.log("Attach std listeners")
    child.stdout.on('data', data => console.log("Child stdout:", String(data)));
    child.stderr.on('data', data => console.log("Child stderr:", String(data)));
}

child.on('close', (...args) => { console.log("Child closed", args); });

Running node test.js produces following in Ubuntu terminal for me:

Attach std listeners
CLOSED [ 0, null ]

(when I run it on macOS, I get as expected multiple Child stdout: Other text in output)

While if I change stdio to inherit in main script, the output from child process is exposed:

Some text
Other text
Other text
Other text
Other text
Other text
Other text
Other text
Other text
Other text
Child closed [ 0, null ]

It signals to me that the child process is run without issues but for some reason, no stdout and stderr are emitted by a child when its output is supposed to be piped.

The same issue occurs with other Node.js versions I've checked (v14, v17, v18nightly)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It appears the problem is when Node.js is installed via Snap dependency manager (so official Ubuntu Software installer).

Software is then sandboxed in read-only containers, with restricted access to other system parts, and as it shows that cannot work for Node.js

Solution: Do not install Node.js via Snap, install via apt instead

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda