jehna / humanify

Deobfuscate Javascript code using ChatGPT
MIT License
1.21k stars 51 forks source link

Error: process.stdout.cursorTo is not a function #57

Open sandiwp opened 2 weeks ago

sandiwp commented 2 weeks ago

echo "OPENAI_API_KEY=api key..." > .env && humanify openai main.js export OPENAI_API_KEY="api key..." && humanify openai main.js OPENAI_TOKEN=api key... humanify openai main.js humanify --apiKey="api key..." main.js file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:67 process.stdout.cursorTo(0); ^

TypeError: process.stdout.cursorTo is not a function at showPercentage (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:67:20) at visitAllIdentifiers (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56606:35) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56720:12 at async unminify (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:196:27) at async Command. (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56790:3)

Node.js v20.17.0 file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:67 process.stdout.cursorTo(0); ^

TypeError: process.stdout.cursorTo is not a function at showPercentage (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:67:20) at visitAllIdentifiers (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56606:35) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56720:12 at async unminify (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:196:27) at async Command. (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56790:3)

Node.js v20.17.0 file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:67 process.stdout.cursorTo(0); ^

TypeError: process.stdout.cursorTo is not a function at showPercentage (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:67:20) at visitAllIdentifiers (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56606:35) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56720:12 at async unminify (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:196:27) at async Command. (file:///C:/Users/Rahim/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56790:3)

Node.js v20.17.0 error: unknown option '--apiKey=api key...'

Usage: humanify [options] [command]

Unminify code using OpenAI's API or a local LLM

jehna commented 2 weeks ago

Which environment are you running humanify on? It seems that your terminal/stdout/something does not support clearing the row. You should be able to fix this for now by using --verbose flag, which disables the clearing. I'll fix the underlying issue in coming versions.

jehna commented 2 weeks ago

And thank you for reporting the issue! 🙇

sandiwp commented 2 weeks ago

Thank you very much for your support

It worked fine when I used it before and now it doesn't work

Another thing I know is that I did console.log in different places but it doesn't display in the command lines but they are executing as far as I understand.

jehna commented 2 weeks ago

I checked into this more. Is it possible by any chance that you're trying to run humanify using an old node.js? It seems that stdout.cursorTo is introduced in node.js version 17, so this implies that your node.js version would have been under that. I confused that previously with stdout.clearLine, which would be absent in weird terminal environments

jehna commented 2 weeks ago

You can check via node --version