eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
Latest release is broken with eslint 8
Eslint-plugin-sonarjs peerDependencies conflicts
Help with eslint install and dependency problem
» npm install eslint
» npm install @eslint/js
**English is not my first language. Sorry if I made any mistakes or didn't clearly explain the problem.
I've been trying to install eslint for days, but every time, I get this error with the dependency. I've tried everything that i could think and find on the internet to fix it... I don't know why this is happening because it worked fine previously in other projects. I even tried to unistall Prettier, but I couldn't even do that.
Thinking that the problem might be my laptop, I used my mom's. I downloaded everything from git and vscode to node, and yet again, the same problem..... (Side note: strangely, it stopped asking me what format the project would use - in this case, it'd would be JSON - when answering npx eslint --init questions).
I'm going to describe every step I follow so you can tell me if the problem is here:
terminal: npx create-react-app projectName --template typescript
vscode: create .editorconfig file
vscode terminal: npm i --save-dev @typescript-eslint/eslint-plugin@latest eslint-plugin-react@latest @typescript-eslint/parser@latest eslint@latest --legacy-peer-deps
npx eslint --init after that:
check sintax and find problems
import/export
react
yes
browser
JSON (but it's not asking this anymore, so it creates eslint.config.mjs instead of .eslintrc.json)
yes
npm
and it shows this dependency error.... can someone help me, please? I'm quite literally going insane
Credit to Brad Zacher's answer for drawing my attention to How do I check to see what versions are installed?
If you have multiple versions of our tooling, it can cause various bugs for you. This is because ESLint may load a different version each run depending on how you run it - leading to inconsistent lint results.
Installing our tooling in the root of your project does not mean that only one version is installed. One or more of your dependencies may have its own dependency on our tooling, meaning npm/yarn will additionally install that version for use by that package. For example, react-scripts (part of create-react-app) has a dependency on our tooling.
You can check what versions are installed in your project using the following commands:
npm
npm list @typescript-eslint/eslint-plugin @typescript-eslint/parserYarn
yarn list --pattern "@typescript-eslint/eslint-plugin|@typescript-eslint/parser"pnpm
pnpm list @typescript-eslint/eslint-plugin @typescript-eslint/parserIf you see more than one version installed, then you will have to either use yarn resolutions to force a single version, or you will have to downgrade your root versions to match the dependency versions.
The best course of action in this case is to wait until your dependency releases a new version with support for our latest versions.
I used the yarn command, which gave the following output
yarn list v1.22.19
├─ @typescript-eslint/[email protected]
├─ @typescript-eslint/[email protected]
└─ [email protected]
├─ @typescript-eslint/[email protected]
└─ @typescript-eslint/[email protected]
So the solution was to downgrade @typescript-eslint/eslint-plugin and @typescript-eslint/parser to version 5.62.0 in my package.json, to match the version used by eslint-config-react-app.
I then hit a different error:
There was a problem loading formatter: ...\node_modules\eslint\lib\cli-engine\formatters\stylish Error: require() of ES Module ...\node_modules\strip-ansi\index.js from ...\assertion-lib\node_modules\eslint\lib\cli-engine\formatters\stylish.js not supported. Instead change the require of index.js in ...\node_modules\eslint\lib\cli-engine\formatters\stylish.js to a dynamic import() which is available in all CommonJS modules.
Manually editing something in the node_modules folder didn't sound right, however it seems that this is a bug in yarn. So I deleted the yarn.lock file from my project and deleted the node_modules folder (which may have been overkill) and ran a npm install and now eslint is linting my typescript code successfully.
ESLint is warning you that there are multiple versions of the plugin installed in your workspace, and that your configuration is setup so that you've asked ESLint to import these multiple versions.
So either you'll need to change your config to avoid this, or (more likely) you'll need to use your package manager's resolutions feature to ensure there's only one version of the plugin installed.
This FAQ article might help as it lists some commands and provides some more context: https://typescript-eslint.io/linting/troubleshooting/#how-do-i-check-to-see-what-versions-are-installed