suppress-eslint-errors icon indicating copy to clipboard operation
suppress-eslint-errors copied to clipboard

Latest version errors on run as it require()s ES modules

Open callumacrae opened this issue 2 years ago • 5 comments

hey! excited to use this module :)

/Users/callumacrae/.nvm/versions/node/v16.13.1/lib/node_modules/suppress-eslint-errors/bin/index.js:11
const chalk = require('chalk');
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/callumacrae/.nvm/versions/node/v16.13.1/lib/node_modules/suppress-eslint-errors/node_modules/chalk/source/index.js from /Users
/callumacrae/.nvm/versions/node/v16.13.1/lib/node_modules/suppress-eslint-errors/bin/index.js not supported.
Instead change the require of /Users/callumacrae/.nvm/versions/node/v16.13.1/lib/node_modules/suppress-eslint-errors/node_modules/chalk/source/index.js in /Users/callumacrae/.nvm/ve
rsions/node/v16.13.1/lib/node_modules/suppress-eslint-errors/bin/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/callumacrae/.nvm/versions/node/v16.13.1/lib/node_modules/suppress-eslint-errors/bin/index.js:11:15) {                                                code: 'ERR_REQUIRE_ESM'
}

I get errors about this and other modules which were updated by dependabot, e.g. chalk - https://github.com/chalk/chalk/releases/tag/v5.0.0

There's more than one so I'd suggest that the best fix would probably be to switch the imports out in this module rather than downgrade the other modules.

As a workaround, 2.0.4 works fine :)

callumacrae avatar Mar 09 '22 11:03 callumacrae

I’d be happy to accept a PR that fixes the issue!

(especially if it adds a couple of integration tests for the main entry point, so that this doesn’t happen again)

amanda-mitchell avatar Mar 09 '22 18:03 amanda-mitchell

I looked at the most recent version diff

Wasn't anything obvious! But I remember seeing chalk referenced in the error message I got.

Found this: https://github.com/chalk/chalk/releases/tag/v5.0.0

If you use TypeScript, you will want to stay on Chalk 4 until TypeScript 4.6 is out. https://github.com/microsoft/TypeScript/issues/46452

It's totally fine to stay on Chalk v4. It's been stable for years.

So I think the play is just to rollback the dependency update for chalk, until TS 4.6 has had time to matriculate.

leggomuhgreggo avatar Mar 18 '22 19:03 leggomuhgreggo

So I think the play is just to rollback the dependency update for chalk,

I already tried that, there's other modules that have been updated with the same issue too

also, this project isn't using TS - this isn't a problem that will be fixed by waiting for an update

callumacrae avatar Mar 21 '22 11:03 callumacrae

I believe downgrading chalk to version 4 should fix this:

https://github.com/amanda-mitchell/suppress-eslint-errors/pull/290

DerekTBrown avatar Jun 16 '22 00:06 DerekTBrown

chalk v5.0.1 added CJS compatibility back so upgrading might be a better choice.

hytor-yang avatar Jul 19 '22 09:07 hytor-yang

With chalk 5.1.2 I still have the problem

hedgepigdaniel avatar Oct 25 '22 02:10 hedgepigdaniel

Issue is still persisting

MoSattler avatar Mar 07 '23 12:03 MoSattler

Fixed in 3.0.1

amanda-mitchell avatar Aug 26 '23 18:08 amanda-mitchell

Thank you very much @amanda-mitchell !

MoSattler avatar Aug 27 '23 08:08 MoSattler