Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
chalk package issue in nodejs

**When I require to chalk package in node js like as **

index.js

 const  chalk  = require('chalk');
 console.log(chalk.bgRed.inverse("hello world"));
 console.log(chalk.blue.inverse('Hello') + ' World' + chalk.red('!'));

package.json

{
"name": "npm_mod",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"

}, "author": "rahul", "license": "ISC", "dependencies": { "chalk": "^5.0.0", "type": "module" } }

when I run code then show the issue and how to deal with this issue without using .mjs file

internal/modules/cjs/loader.js:1089
  throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
  ^
 Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: R:\24-01-22-nodeJs\npm_mod\node_modul

json.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The error above is because you're using the Common.JS module require syntax rather than the ES module import syntax.

Update:

const chalk = require('chalk')

to be:

import chalk from 'chalk'
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!