-
-
Notifications
You must be signed in to change notification settings - Fork 55
Description
I've ended up down a bit of a rabbit hole trying to get eslint-plugin-import-x
working in VSCode. I'm consistently getting this error when I introduce eslint-plugin-import-x
:
Error: Cannot find native binding. npm has a bug related to optional dependencies (npm/cli#4828). Please try
npm i
again after removing both package-lock.json and node_modules directory.
Example broken project: https://github.com/matburnham/broken-native-bindings
From the command line, all appears to be good:
mat@devbox:~/dev/broken-native-bindings$ pnpm -v
10.15.1
mat@devbox:~/dev/broken-native-bindings$ node --version
v22.16.0
mat@devbox:~/dev/broken-native-bindings$ pnpm npx eslint
mat@devbox:~/dev/broken-native-bindings$ pnpm npx eslint
/home/mat/dev/broken-native-bindings/index.ts
1:26 warning '/home/mat/dev/broken-native-bindings/index.ts' imported multiple times import-x/no-duplicates
2:21 warning '/home/mat/dev/broken-native-bindings/index.ts' imported multiple times import-x/no-duplicates
✖ 2 problems (0 errors, 2 warnings)
0 errors and 1 warning potentially fixable with the `--fix` option.
But then I try to do the same inside VSCode with the dbaeumer.vscode-eslint
extension:
2025-09-07 21:36:55.068 [info] ESLint server is starting.
2025-09-07 21:36:55.068 [info] ESLint server running in node v22.17.0
2025-09-07 21:36:55.087 [info] ESLint server is running.
2025-09-07 21:37:02.454 [info] ESLint library loaded from: \\devbox\mat\dev\broken-native-bindings\node_modules\eslint\lib\api.js
2025-09-07 21:37:34.481 [error] Calculating config file for file://devbox/mat/dev/broken-native-bindings/index.ts) failed.
Error: Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
at //devbox/mat/dev/broken-native-bindings/node_modules/unrs-resolver/index.js:376:11
at eval_evalModule (\\devbox\mat\dev\broken-native-bindings\node_modules\jiti\dist\jiti.cjs:1:199388)
at \\devbox\mat\dev\broken-native-bindings\node_modules\jiti\dist\jiti.cjs:1:197618
at async import (\\devbox\mat\dev\broken-native-bindings\node_modules\jiti\dist\jiti.cjs:1:202945)
at async //devbox/mat/dev/broken-native-bindings/node_modules/eslint-plugin-import-x/lib/node-resolver.js:3:21
at async import (\\devbox\mat\dev\broken-native-bindings\node_modules\jiti\dist\jiti.cjs:1:202945)
at async //devbox/mat/dev/broken-native-bindings/node_modules/eslint-plugin-import-x/lib/index.js:18:21
at async import (\\devbox\mat\dev\broken-native-bindings\node_modules\jiti\dist\jiti.cjs:1:202945)
at async //devbox/mat/dev/broken-native-bindings/eslint.config.mts:4:28
at async Function.import (\\devbox\mat\dev\broken-native-bindings\node_modules\jiti\dist\jiti.cjs:1:202945)
Clearly there's some difference in configuration between running in VSCode and running on the command line. I've tried all sorts of config options and fiddled with precompiled native packages but can't figure out the cause. I'm running VSCode on Windows, with a remote SSH connection to a Ubuntu VMWare machine.
I imagine it's somewhere between pnpm
, eslint-plugin-import-x
, vscode-eslint
, using VSCode with a remote server, and me.
If I remove the references to eslint-plugin-import-x
from my config all is fine. Where should I look next to solve the problem, short of giving up on eslint-plugin-import-x
?