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

326
Views
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
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!