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

329
Vistas
Why stdout.write() is not working in Terminal?

I am novice in Node JS.

I am trying to test cURL request on my localhost:3000 port. I am using Sublime Text 4 text editor. cURL request on Windows Terminal works fine but Loading Bar is not showing up in terminal. Instead it is showing up in Sublime Text Console.

Sublime Text Console

Here's Terminal Output without loading bar

Windows Terminal Output

I've tried the following code :

const chalk = require("chalk");
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const express = require("express");
const app = express();

const processes = require("process");
const rdl = require("readline");

class LoadingBar {
    constructor(size) {
        this.size = size;
        this.cursor = 0;
        this.timer = null;
    }
    start() {
        processes.stdout.write("\x1B[?25l");
        processes.stdout.write("[");
        for (let i = 0; i < this.size; i++) {
            processes.stdout.write("-");
        }
        processes.stdout.write("]");
        this.cursor = 1;
        rdl.cursorTo(processes.stdout, this.cursor, 0);
        this.timer = setInterval(() => {
            processes.stdout.write("#");
            this.cursor++;
            if (this.cursor >= this.size) {
                clearTimeout(this.timer);
                processes.stdout.write("\x1B[?25h");
            }
        }, 100);
    }
}

const loader = new LoadingBar(25);

const obj = {
    "Response": 200,
    "Operation": 'successful',
};

app.get("/response", (req, res) => {
    loader.start();
    res.json(obj);
});

app.listen(3000, () => {
 console.log("Server running on port 3000");
});

I want to make cURL request from Terminal and after that Loading Bar will show up and then I will get the obj. But for some reasons stdout.write() is not working in Terminal. What should I do?

about 4 years ago · Santiago Gelvez
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