Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint Error: when installed with yarn #8976

Open
anjantalatam opened this issue Aug 17, 2023 · 4 comments
Open

ESLint Error: when installed with yarn #8976

anjantalatam opened this issue Aug 17, 2023 · 4 comments

Comments

@anjantalatam
Copy link

anjantalatam commented Aug 17, 2023

yarn version: 1.22.19

Bug: ESLint is throwing the below error when yarn run lint is executed given ESLint is installed with yarn.

package.json

  "scripts": {
    "lint": "eslint src",
  }

Complete error:

There was a problem loading formatter: <path_to_node_project>/node_modules/eslint/lib/cli-engine/formatters/stylish
Error: require() of ES Module <path_to_node_project>/node_modules/strip-ansi/index.js from <path_to_node_project>/api/node_modules/eslint/lib/cli-engine/formatters/stylish.js not supported.
Instead change the require of index.js in <path_to_node_project>/node_modules/eslint/lib/cli-engine/formatters/stylish.js to a dynamic import() which is available in all CommonJS modules.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here is a discussion from eslint eslint/eslint#17215 (comment)

yarn run lint working fine when ESLint is installed with npm or pnpm

anthonyblond added a commit to australiangreens/ag-internal-components that referenced this issue Aug 18, 2023
@baryman
Copy link

baryman commented Sep 16, 2023

Will be fix this problem? Can't setting project with eslint using yarn... It makes me sad 😢

@ArloL
Copy link

ArloL commented Sep 16, 2023

It works with newer versions of yarn. IMHO it's unlikely this will be fixed because it's not a security issue. The yarn upgrade is easy and you get a whole bunch of features and performance improvements.

@vozmi
Copy link

vozmi commented Sep 20, 2023

Removing yarn.lock and reinstalling packages with yarn install can fix the problem. But it can occur again (for instance, when changing git branches).

UPD from eslint discussion: can be fixed by downgrading strip-ansi version in package.json by adding:

 "resolutions": {
    "strip-ansi": "^6.0.1"
}

@isaacs
Copy link

isaacs commented Jan 10, 2024

Reproduction case: eslint/eslint#17215 (reply in thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants