[Deps] let user know eslint-import-resolver-node needs to be in root of node_modules (important when using install-strategy=linked) - #3266
Conversation
…t of node_modules (important when using `install-strategy=linked`) Using `install-strategy=linked` only puts the packages from `dependencies` and `devDependencies` in the root of node_modules. This means that `eslint-import-resolver-node` is not in the root of node_modules which leads to the following error: ``` Resolve error: unable to load resolver "node" ``` This is fixed by adding `eslint-import-resolver-node` to your `package.json`. We signal this to the user by adding `eslint-import-resolver-node` to `peerDependencies`. `install-strategy=linked` is stable since `npm@11.18.0`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3266 +/- ##
=======================================
Coverage 79.58% 79.58%
=======================================
Files 98 98
Lines 4527 4527
Branches 1560 1560
=======================================
Hits 3603 3603
Misses 924 924 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This fix can also be added to the fix in #2283 and then we can close this PR. |
|
I see the dependency is already being declared correctly. eslint-plugin-import/package.json Line 125 in bf2d2aa |
The problem is the way the dependency is being resolved here: eslint-plugin-import/utils/resolve.js Lines 101 to 103 in bf2d2aa The only way this works is if |
Yes, that is what I was going to write. That require logic may need to be updated to ensure it works in isolated dependencies layout. |
|
This is intentional, and is why the "linked" strategy (and yarn's PNP, and similar approaches) is fundamentally flawed. Adding it to peer deps explicitly increases maintenance burden and could be a breaking change. |
|
But the CI is broken because of npm v12. |
|
the npm 12 thing is fixed, if you rebase. |
| "peerDependencies": { | ||
| "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9 || ^10" | ||
| "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9 || ^10", | ||
| "eslint-import-resolver-node": "^0.4.0" |
There was a problem hiding this comment.
note that this is a breaking change, because it will fail if someone has a newer version installed at a higher level.
Your commit seems to have used another failure - https://github.com/import-js/eslint-plugin-import/actions/runs/29535690274/job/87764990067 |
Thanks for the more thorough fix, @manzoorwanijk. If that PR is merged, we can close my PR. |
Using
install-strategy=linkedonly puts the packages fromdependenciesanddevDependenciesin the root of node_modules. This means thateslint-import-resolver-nodeis not in the root of node_modules which leads to the following error:This is fixed by adding
eslint-import-resolver-nodeto yourpackage.json. We signal this to the user by addingeslint-import-resolver-nodetopeerDependencies.install-strategy=linkedis stable sincenpm@11.18.0: https://docs.npmjs.com/cli/v11/using-npm/config#install-strategynpm even recommends using it when developing. From the above link:
There is a closed (but unresolved) issue for this: #828