Problem using process.stdout.cursorTo() command in npm terminal

Running script from the npm panel fail on process.stdout.cursorTo(0) but running the same script from terminal using npm run "script" does not.

but running exactly the same from console...

 

0
3 comments

clearLine and cursorTo are undefined when process.stdout is not a tty. And Node/NPM console in WebStorm is non-Tty, as node process is started with input/output streams redirection. Please see https://youtrack.jetbrains.com/issue/WEB-1933.
Note that these functions are no longer documented as part of process.stdout. This code has moved to redline (https://nodejs.org/dist/latest-v4.x/docs/api/readline.html)

readline.cursorTo(process.stdout, 0);
1
Avatar
Permanently deleted user

Hey Elena, thank you for your reply.

I have found a similar answer online so I suspected that it was due to being non-TTY, in that post they suggested to use 'readline' module of node.js that has a cursorTo and clearLine, and although that using those does not cause the error the cursor does not move to the desired position.

0

>although that using those does not cause the error the cursor does not move to the desired position.

readline cursorTo(), etc. methods are still TTY methods - though they are defined in non-TTY environment, so no errors are thrown, they still require TTY environment to work 

0

Please sign in to leave a comment.