debug icon indicating copy to clipboard operation
debug copied to clipboard

require('supports-color') will always fail, supports-color version 9+ for node

Open JakeCB opened this issue 3 years ago • 0 comments

https://github.com/chalk/supports-color/releases/tag/v9.0.0

supports-color moved to ESM so require() always fails. Just add a breakpoint/log here to confirm.

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/node_modules/supports-color/index.js from /home/node_modules/debug/src/node.js not supported.
Instead change the require of index.js in /home/node_modules/debug/src/node.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/node_modules/debug/src/node.js:32:24)
    at Object.<anonymous> (/home/node_modules/debug/src/index.js:9:19)
    at Object.<anonymous> (/home/src/x.js:7:33)
    at Object.<anonymous> (/home/src/x.js:4:18)
    at async Promise.all (index 0) {
  code: 'ERR_REQUIRE_ESM'
}

Work around is "supports-color": "^8.1.1" when adding supports-color as a dependency.

JakeCB avatar Sep 09 '22 17:09 JakeCB