I have problem in changing the color in the console, I have imported nmp modules chalk but it is showing ESM require error. I don't understand

130 views Asked by At

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 answers

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');