How to resolve the ESM require problem, I have tried a lot to resolve it but I was unable to fix this out.

1

There are 1 best solutions below

0
lmao On

https://www.npmjs.com/package/chalk#install

IMPORTANT: Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. Read more.

For chalk 5 and above you'll need import statement:

import chalk from 'chalk';

Otherwise, use chalk 4 with require statement:

const chalk = require('chalk');