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

225
Views
How to run a CLI nodejs app on different TTYs?

My app should print logs and run a node.js REPL. But logs mess up the REPL, so I tried to run the REPL in another TTY.

Here is a sample code:

// app.js

const fs = require('fs')
const repl = require('repl')
const getTTYFile = () => '/dev/pts/4' // TODO

const TTYFile = getTTYFile()

let read = fs.createReadStream(TTYFile)
let write = fs.createWriteStream(TTYFile)
repl.start({
    input: read, output: write,
    terminal: true, useColors: true
})

setInterval(() => console.log('I am log'), 1000)

I opened a terminal tab without shells in KDE. Then I started my nodejs app:

konsole --new-tab --hold -e tty # outputs `/dev/pts/4`
node app.js

Here are the problems:

  • Input echoes twice, screenshot: konsole
  • Read-line doesn't work (Can not move the cursor or clear screen...).

How should I fix my code?

about 4 years ago · Juan Pablo Isaza
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!