question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint --init won't work with npm >=7

See original GitHub issue

Tell us about your environment

  • ESLint Version: 7.23.0
  • Node Version: 12.21.0
  • npm Version: 7.8.0
  • Operating System: Ubuntu 20.04

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using? @typescript-eslint/parser

Please show your full configuration:

✔ How would you like to use ESLint? · style
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · react
✔ Does your project use TypeScript? · No / Yes
✔ Where does your code run? · browser
✔ How would you like to define a style for your project? · guide
✔ Which style guide do you want to follow? · standard
✔ What format do you want your config file to be in? · JavaScript
Checking peerDependencies of eslint-config-standard@latest
The config that you've selected requires the following dependencies:

eslint-plugin-react@latest @typescript-eslint/eslint-plugin@latest eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 eslint-plugin-node@^11.1.0 eslint-plugin-promise@^4.2.1 @typescript-eslint/parser@latest
✔ Would you like to install them now with npm? · No / Yes
Installing eslint-plugin-react@latest, @typescript-eslint/eslint-plugin@latest, eslint-config-standard@latest, eslint@^7.12.1, eslint-plugin-import@^2.22.1, eslint-plugin-node@^11.1.0, eslint-plugin-promise@^4.2.1, @typescript-eslint/parser@latest

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

yarn add -D eslint@latest
npx eslint --init
npx eslint --init

What did you expect to happen?

Install eslint with required dependencies

What actually happened? Please copy-paste the actual, raw output from ESLint.

✔ How would you like to use ESLint? · style
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · react
✔ Does your project use TypeScript? · No / Yes
✔ Where does your code run? · browser
✔ How would you like to define a style for your project? · guide
✔ Which style guide do you want to follow? · standard
✔ What format do you want your config file to be in? · JavaScript
Checking peerDependencies of eslint-config-standard@latest
The config that you've selected requires the following dependencies:

eslint-plugin-react@latest @typescript-eslint/eslint-plugin@latest eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 eslint-plugin-node@^11.1.0 eslint-plugin-promise@^4.2.1 @typescript-eslint/parser@latest
✔ Would you like to install them now with npm? · No / Yes
Installing eslint-plugin-react@latest, @typescript-eslint/eslint-plugin@latest, eslint-config-standard@latest, eslint@^7.12.1, eslint-plugin-import@^2.22.1, eslint-plugin-node@^11.1.0, eslint-plugin-promise@^4.2.1, @typescript-eslint/parser@latest
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: @typescript-eslint/eslint-plugin@3.10.1
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR!   @typescript-eslint/eslint-plugin@"^3.1.0" from @react-native-community/eslint-config@2.0.0
npm ERR!   node_modules/@react-native-community/eslint-config
npm ERR!     dev @react-native-community/eslint-config@"^2.0.0" from the root project
npm ERR!   dev @typescript-eslint/eslint-plugin@"4.20.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @typescript-eslint/eslint-plugin@"4.20.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @typescript-eslint/parser@4.20.0
npm ERR! node_modules/@typescript-eslint/parser
npm ERR!   peer @typescript-eslint/parser@"^4.0.0" from @typescript-eslint/eslint-plugin@4.20.0
npm ERR!   node_modules/@typescript-eslint/eslint-plugin
npm ERR!     dev @typescript-eslint/eslint-plugin@"4.20.0" 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! See /home/fbillioud/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fbillioud/.npm/_logs/2021-04-02T11_51_18_888Z-debug.log

Oops! Something went wrong! :(

Steps to reproduce this issue:

  1. install npm >= 7
  2. create a new project
  3. run eslint --init

Are you willing to submit a pull request to fix this bug?

I’m not sure about where the related code is, but if someone indicates this to me, we could probably switch npm to yarn which appears to be way more reliable in many aspects. Otherwise, we could test the version of npm being used, and add --legacy-peer-deps if needed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Apr 15, 2021

Yeah, this seems like a bug. We probably need to do something about peer dependencies at this stage of the process.

1reaction
ljharbcommented, Apr 2, 2021

Even with npm 7, it’s better to explicitly install peer deps so they show up in package.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESlint Error Install from Command Line - Stack Overflow
For: Zsh: command not found: eslint npm install eslint-plugin-react-hooks --save --dev. then run: npm install -g eslint. It should work.
Read more >
ESLint - npm
An AST-based pattern checker for JavaScript.. Latest version: 8.30.0, last published: 12 days ago. Start using eslint in your project by ...
Read more >
Getting Started with ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
npm eslint --init Code Example
Answers related to “npm eslint --init”. install eslint · eslint init · running eslint · how to add eslint to your JavaScript project...
Read more >
Adding ESlint to Your Project - Medium
Here we have a simple model in mongoose, but it doesn't look so… ... npm i eslint -D ... And run the init...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found