sindresorhus / ora

Elegant terminal spinner
MIT License
9.08k stars 269 forks source link

TypeError: Cannot destructure property 'stdout' of 'supportsColor' as it is undefined. #230

Closed Kamrulhasan12345 closed 11 months ago

Kamrulhasan12345 commented 11 months ago

I am facing the following issue while trying to use ora in my typescript app:

const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
               ^

TypeError: Cannot destructure property 'stdout' of 'supportsColor' as it is undefined.
    at <anonymous> (f:\hemel_vai_dl\node_modules\chalk\source\index.js:8:16)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

What could be the reason of it?

NodeJS version: 18.15 Machine: Windows

Works fine on my bun installation in WSL2, but this problem on windows machine and nodejs itself, idk what's the reason.

sindresorhus commented 11 months ago

Make sure your project is ESM.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Kamrulhasan12345 commented 11 months ago

My project is ESM. Maybe I faced issues due to tsconfig things while working with tsm (I don't know exactly). But after transpiling into js, I got that working perfectly. Thanks a lot for the suggestion.