Chalk [ERR_REQUIRE_ESM]

Hi. I was ended my bots problem and another one come but i don’t know how to fix it.

Hi @Bay_Kedi, welcome to the forum.

This error is because your project is an ‘ESM’ project, which expects the new style of importing packages, and you are using the older ‘CommonJS’ style.

I think the solution is to replace:

const chalk = require('chalk');

with this:

import chalk from 'chalk';

Hope it helps :slight_smile:

I can’t do it because it disconnects. When it connects, it’s sending me to another file and turns back into the old one.
And this is the logs
image

Ok i get it. I need to open space in the disk.
Can I get free disk for 24 hours?

try using git prune; git gc. it should probably save you some extra disk space

Keep in mind this is only my guess but I’m going to guess that your problem is not what you think it is.

It is a Discord Bot right? Did it ever run or you just decided to incorporate this library before testing? I’d remove the requirement for Chalk and get a good build that runs. Check the available disk space recognizing that node modules should not be counted towards the basic disk limit.

If you see that the node_modules folder is reducing your available disk space you need to contact support and explain it.

Chalk appears to be about 41.3K I don’t think you are that close. You opted for the ESM version, given what I can see your Bot is not. Chalk recommends you use version 4 in that case. It also appears to be tool for colorizing console.log output. May not be worth the effort in the long run.

It could be other things. You might consider is sharing your package.json file here so we can see if there are any obvious problems.

{
  "name": "kedistan botu",
  "version": "0.0.1",
  "author": "kedistan botu altyapı",
  "main": "bot.js",
  "scripts": {
    "start": "node bot.js"
  },
  "dependencies": {
    "canvas": "^2.8.0",
    "chalk": "^5.0.0",
    "discord-logs": "^2.0.1",
    "discord.js": "^13.4.0",
    "express": "^4.17.2",
    "google-tts-api": "^2.0.2",
    "jimp": "^0.16.1",
    "moment": "^2.29.1",
    "moment-duration-format": "^2.3.2",
    "mongoose": "^6.1.3",
    "node-superfetch": "^0.2.3",
    "opusscript": "^0.0.8",
    "parse-ms": "^3.0.0",
    "quick.db": "^7.0.0b22",
    "request": "^2.88.2",
    "node": "^17.3.0",
    "npm": "^8.3.0",
    "node-fetch": "^3.1.0",
    "esm": "^3.2.25",
    "gitignore": "^0.7.0"
  },
  "engines": {
    "node": "16.x"
  },
  "license": "MIT",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}

I redownloaded the source now its normal
image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.