Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda