» npm install eslint
Videos
» npm install @angular-eslint/eslint-plugin
Factsheet
» npm install typescript-eslint
» npm install eslint-plugin-react
» npm install eslint-plugin-n
I can't figure this out. Running eslint works but I can't do npm install anymore. I just followed the official docs for setup.
This is the error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: typescript-eslint@7.16.1
npm ERR! Found: eslint@9.7.0
npm ERR! node_modules/eslint
npm ERR! dev eslint@"^9.7.0" from the root project
npm ERR! peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from u/eslint-community/eslint-utils@4.4.0
npm ERR! node_modules/@eslint-community/eslint-utils
npm ERR! u/eslint-community/eslint-utils@"^4.2.0" from eslint@9.7.0
npm ERR! u/eslint-community/eslint-utils@"^4.4.0" from u/typescript-eslint/utils@7.16.1
npm ERR! node_modules/typescript-eslint/node_modules/@typescript-eslint/utils
npm ERR! u/typescript-eslint/utils@"7.16.1" from typescript-eslint@7.16.1
npm ERR! node_modules/typescript-eslint
npm ERR! dev typescript-eslint@"^7.16.1" from the root project
npm ERR! 2 more (@typescript-eslint/eslint-plugin, u/typescript-eslint/type-utils)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^8.56.0" from typescript-eslint@7.16.1
npm ERR! node_modules/typescript-eslint
npm ERR! dev typescript-eslint@"^7.16.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint@8.57.0
npm ERR! node_modules/eslint
npm ERR! peer eslint@"^8.56.0" from typescript-eslint@7.16.1
npm ERR! node_modules/typescript-eslint
npm ERR! dev typescript-eslint@"^7.16.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/user/.npm/_logs/2024-07-19T18_04_24_783Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /Users/user/.npm/_logs/2024-07-19T18_04_24_783Z-debug-0.log
You can install Node modules within the project (locally) or globally. To switch to globally, you may use the -g flag, like so:
npm install -g eslint
Then see if it's working without Sublime Text (-v flag to see the version of eslint):
eslint -v
To see where it was installed (assuming MacOS/Linux):
which eslint
Then see if it's working in Sublime Text (you may need to restart Sublime first). If it's not working, make sure in the eslint package settings that the path is correct.
To install eslint globally:
npm install -g eslintTo install eslint in your project folder:
npm install eslint --save-devAdd in
package.jsonthis script :"eslint": "eslint --ignore-path .gitignore ."Create a file called
.eslintrcand insert :{ "env": { "browser": true, "node": true }, "globals": { "chrome": true }, "rules": { "no-console": 0, "no-empty": [1, { "allowEmptyCatch": true }] }, "extends": "eslint:recommended" }Personally, I save this file in my js folder
Go to
node_modules/.bin- Run :
eslint --initornpm run eslint nameOfYourFile