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

220
Vistas
How do you dynamically change/overwrite a console log with Node.js?

I'm working with JavaScript/Node and have a Websocket with a server that is sending a constantly updating string. My goal is to log the string dynamically in the console, so if the sequence of strings from the stream is [string1, string1, string2, string2, string2, string3], then rather than have the console show

string1
string1
string2
string2
string2
string3

I want the console to show

stringI

Where stringI is constantly updating and I is in {1,2,3}

Currently, I'm doing this with

process.stdout.clearLine(0)
process.stdout.cursorTo(0)
process.stdout.write(new_string)

But I run into issues when the string is greater than one line length in the console.

Does anyone know how I can dynamically overwrite a constantly updating string in the console? Thanks!

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

0

truncation could be an easy option:

const { exec } = require("child_process");
exec("truncate -s 0 console.log");
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