androidjs-builder icon indicating copy to clipboard operation
androidjs-builder copied to clipboard

NodeJS Error/Fix process.stdout.clearLine not found

Open Cupidazul opened this issue 3 years ago • 1 comments

Error occurs in node 14.x. process.stdout.clearLine and cursorTo not found ...

Fix: ProgressBar.js

class LoadingBar {
    constructor() {
        this.interval = 100;
        this.currentIndex = 0;
        this.fill = '█';
        this.empty = '⣿';
        this.bar_length = 50;
        this.loop = null;
        this.flip = 1;
        this.chunksDownloaded = "0";
        this.isRunning = false;
        this.success = ' √';
        this.failed = ' X';
        this.message = '';
        this.messageSize = 0;
    }
    reset() {
        this.constructor();
    }
    next() {
        this.clear();
        this.currentIndex += this.flip;
        if (this.currentIndex === this.bar_length || this.currentIndex === 0) {
            this.flip *= -1;
        }
        let _left = this.currentIndex - 1;
        _left = _left 0) process.stdout.write('\b'.repeat(this.messageSize));
        }
    }

.
.
.
.

Cupidazul avatar Aug 03 '22 09:08 Cupidazul

This is still an issue, and has been an issue for quite some time.

Also referenced in the main AndroidJS repo: https://github.com/android-js/androidjs/issues/161

And the error I got from attempting to just build a plain, freshly-generated AndroidJS project in GitHub Actions:

Run npm run build:prod

> {my project name was here}@0.0.1 build:prod
> androidjs build --release

--release= true
Downloading: https://github.com/android-js/androidjs-sdk/archive/master.zip
/opt/hostedtoolcache/node/20.11.0/x6[4](https://github.com/{my org name was here}/{my repo name was here}/actions/runs/{GA Run ID was here}/job/{GA Job ID was here}#step:7:5)/lib/node_modules/androidjs-builder/modules/Html/ProgressBar.js:36
        process.stdout.clearLine();
                       ^

TypeError: process.stdout.clearLine is not a function
    at LoadingBar.clear (/opt/hostedtoolcache/node/20.11.0/x64/lib/node_modules/androidjs-builder/modules/Html/ProgressBar.js:36:24)
    at LoadingBar.next (/opt/hostedtoolcache/node/20.11.0/x64/lib/node_modules/androidjs-builder/modules/Html/ProgressBar.js:24:14)
    at Timeout._onTimeout (/opt/hostedtoolcache/node/20.11.0/x64/lib/node_modules/androidjs-builder/modules/Html/ProgressBar.js:43:18)
    at listOnTimeout (node:internal/timers:[5](https://github.com/{my org name was here}/{my repo name was here}/actions/runs/{GA Run ID was here}/job/{GA Job ID was here}#step:7:6)[7](https://github.com/{my org name was here}/{my repo name was here}/actions/runs/{GA Run ID was here}/job/{GA Job ID was here}#step:7:8)3:17)
    at process.processTimers (node:internal/timers:514:7)

Node.js v20.[11](https://github.com/{my org name was here}/{my repo name was here}/actions/runs/{GA Run ID was here}/job/{GA Job ID was here}#step:7:12).0
Error: Process completed with exit code 1.

Really does look like it's only that clear() function in the code shown in the snippet posted for this issue that is causing the problem.

AlexStormwood avatar Jan 27 '24 02:01 AlexStormwood