Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

350
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!