Skip to content

Problem with Chalk version #28

@Hevgen

Description

@Hevgen

I have tried to run it in Docker and got next error:

/app/app.js:2
const chalk = require("chalk");
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/chalk/source/index.js from /app/app.js not supported.
Instead change the require of index.js in /app/app.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/app/app.js:2:15) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.20.8

package.json have next line:
"chalk": "^5.3.0"
This causes the problem as I understand: ^5.3.0 is an ES Module-only package, but app.js is written using CommonJS syntax (require(...)), which does not support importing ES modules directly.
So downgrade to "chalk": "^4.1.2" (in package.json) helps. Maybe there is a better solution.

I don't have experience with Node.Js so i have opened the Issue instead of pull request creation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions