chalk/chalk

chalk 5.2.0 with typescript 4.9.5

mamadfar opened this issue · 2 comments

I'm trying to use chalk 5.2.0 with typescript 4.9.5 and also I'm using ESM, but I get the error below:
**Error [ERR_REQUIRE_ESM]: require() of ES Module** C:\Users\msaba\Desktop\new-project\practice\node\express-mongo-ts\node_modules\.pnpm\chalk@5.2.0\node_modules\chalk\source\index.js from C:\Users\msaba\Desktop\new-project\practice\node\express-mongo-ts\src\library\Logging.ts **not supported.**
When I downgrade chalk to 4.1.2 everything works.
Am I doing wrong in using chalk 5.2.0? I read the documentation and I did the same way.
Also, I added type: module to package.json but nothing changed with chalk 5.2.0

That's a sign you are not actually using native ESM.

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

That's a sign you are not actually using native ESM.

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

I read this article and right now I'm using node 18 and 19 (with nvm), so I'm sure that I'm using ESM and by changing type in package.json you can control ESM.