sindresorhus / ora

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

typescript usage #214

Closed dongalor closed 2 years ago

dongalor commented 2 years ago

I'm having problem with using ora spinners in typescript. Is it possible to fix this problem:

Error [ERR_REQUIRE_ESM]: require() of ES Module

Using code right from example:

import ora from 'ora';

const spinner = ora('Loading unicorns').start();

setTimeout(() => {
        spinner.color = 'yellow';
        spinner.text = 'Loading rainbows';
}, 1000);
yakov116 commented 2 years ago

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

anis-marrouchi commented 1 year ago

@dongalor please try this solution and let me know if it worked for you. https://github.com/nooqta/esm-ts

jebarjonet commented 1 year ago

A solution is to use version v5.4.1 of this library instead of the latest version (v6.0.0 has the breaking change with ESM)

@sindresorhus all the work you published in useful libraries is awesome, but that ESM shift on some of them is a pain for many developers. I guess you are tired of reading this, but making those libraries easily usable would be even more awesome 🙂