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.

ERR: undefined when installing eslint-config-airbnb

See original GitHub issue

When running npx install-peerdeps --dev eslint-config-airbnb I get the following error:

install-peerdeps v3.0.3
Installing peerdeps for eslint-config-airbnb@latest.
npm install eslint-config-airbnb@18.2.1 eslint@^7.2.0 eslint-plugin-import@^2.22.1 eslint-plugin-jsx-a11y@^6.4.1 eslint-plugin-react@^7.21.5 eslint-plugin-react-hooks@^1.7.0 --save-dev

ERR undefined

Digging a bit more, I found the following log in my ~/.npm/_logs/ folder:

51 verbose node v16.1.0
52 verbose npm  v7.16.0
53 error code ERESOLVE
54 error ERESOLVE unable to resolve dependency tree
55 error
56 error While resolving: solitaire@0.1.0
56 error Found: eslint@7.28.0
56 error node_modules/eslint
56 error   dev eslint@"^7.2.0" from the root project
56 error   peer eslint@"^5.16.0 || ^6.8.0 || ^7.2.0" from eslint-config-airbnb@18.2.1
56 error   node_modules/eslint-config-airbnb
56 error     dev eslint-config-airbnb@"18.2.1" from the root project
56 error   3 more (eslint-plugin-import, eslint-plugin-jsx-a11y, eslint-plugin-react)
56 error
56 error Could not resolve dependency:
56 error peer eslint@"^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0" from eslint-plugin-react-hooks@1.7.0
56 error node_modules/eslint-plugin-react-hooks
56 error   dev eslint-plugin-react-hooks@"^1.7.0" from the root project
56 error   peer eslint-plugin-react-hooks@"^4 || ^3 || ^2.3.0 || ^1.7.0" from eslint-config-airbnb@18.2.1
56 error   node_modules/eslint-config-airbnb
56 error     dev eslint-config-airbnb@"18.2.1" from the root project
56 error
56 error Fix the upstream dependency conflict, or retry
56 error this command with --force, or --legacy-peer-deps
56 error to accept an incorrect (and potentially broken) dependency resolution.
56 error

To me, it seems like install-peerdeps does not retrieve the correct version of eslint-plugin-react-hooks - instead of getting the latest 4.x version, it gets the 1.7.0 version, which indeed does not support eslint 7.x

Bug has already been reported to eslint-config-airbnb here: https://github.com/airbnb/javascript/issues/2436

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
nathanhleungcommented, Jun 7, 2021

Thanks for this report! Right now the behavior is to grab the last item in the range:

// Semver ranges can have a join of comparator sets
// e.g. '^3.0.2 || ^4.0.0' or '>=1.2.7 <1.3.0'
// Take the last version in the range
const rangeSplit = version.split(" ");
const versionToInstall = rangeSplit[rangeSplit.length - 1];

(from https://github.com/nathanhleung/install-peerdeps/blob/master/src/install-peerdeps.js#L159)

It should be a few-line change to use semver’s sort function to sort the rangeSplit array and grab the latest version – code would look similar to below:

const semverSort = require('semver/functions/sort');

// ...

const sortedRangeSplit = semverSort(rangeSplit);
const versionToInstall = sortedRangeSplit.pop();

If you are willing to take this change on + add some tests to verify it works, this can be a great first PR! Otherwise, I can look into this later this week.

1reaction
AntoineChwatcommented, Jun 7, 2021

Ah so that’s where the issue is, all right well it doesn’t look very complex, I’ll try to give it a go this week then

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERR undefined while installing airbnb eslint - Stack Overflow
First run npm info "eslint-config-airbnb@latest" peerDependencies to check the dependency versions · Use the versions for your own "npm install ...
Read more >
[Solved]-ERR undefined while installing airbnb eslint-node.js
I resolved this by explicitly installing the dependent npm packages i.e. npm install [package]@[version] --save-dev rather than using the npx ...
Read more >
eslint-config-airbnb - npm
This package provides Airbnb's .eslintrc as an extensible shared config. Usage. We export three ESLint configurations for your usage. eslint- ...
Read more >
Airbnb JavaScript Style Guide()
It also assumes you are installing shims/polyfills in your app, ... 3.1 Use the literal syntax for object creation. eslint: no-new-object.
Read more >
Linting React using Airbnb's ESLint Rules
npm install --save-dev eslint-config-airbnb. We now just need to tell ESLint that our own rules extend their Airbnb rules. This uses the Airbnb...
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