Skip to content

Failed to load native binding (Node 22) #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
valleywood opened this issue May 6, 2025 · 5 comments
Closed

Failed to load native binding (Node 22) #447

valleywood opened this issue May 6, 2025 · 5 comments

Comments

@valleywood
Copy link

valleywood commented May 6, 2025

Updated from version 3.8.3 to version 4.3.4 i started getting the following error in VS Code for all my ts/tsx files: (also getting the same error if updating to version v3.10.1 for example)

The error appears on the first line of every ts file for example:
import React from 'react';

The error I'm getting is this:

Resolve error: Failed to load native binding
    at Object.<anonymous> (/Users/valleywood/project/node_modules/unrs-resolver/index.js:372:11)
    at Module._compile (node:internal/modules/cjs/loader:1484:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
    at Module.load (node:internal/modules/cjs/loader:1295:32)
    at Module._load (node:internal/modules/cjs/loader:1111:12)
    at c._load (node:electron/js2c/node_init:2:16955)
    at Module.require (node:internal/modules/cjs/loader:1318:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> /Users/valleywood/project/node_modules/eslint-import-resolver-typescript/lib/index.cjs:8:20)
    at Module._compile (node:internal/modules/cjs/loader:1484:14)eslint[import/no-unresolved](https://github.com/import-js/eslint-plugin-import/blob/v2.31.0/docs/rules/no-unresolved.md)

Reverting to 3.8.3 makes the error disappear.

ChatGpt suggests the following:

This error is due to a native module (likely unrs-resolver) failing to load properly inside a Node + Electron context (as seen from the node:electron/js2c/node_init path). This happens when the native module binary is built for a different runtime than what is trying to use it.

This specific error is often seen with eslint-import-resolver-typescript@4+, which depends on unrs-resolver, a Rust-native module. It's not compatible with Electron or mismatched Node builds unless carefully rebuilt for that environment.

@JounQin
Copy link
Collaborator

JounQin commented May 6, 2025

What environment are you running on? For example, what's the platform? What's the arch?

@valleywood
Copy link
Author

valleywood commented May 7, 2025

What environment are you running on? For example, what's the platform? What's the arch?

Environment:
Architecture: x86_64
ProductName: macOS
ProductVersion: 15.3 (Sequoia)
BuildVersion: 24D60
Chip: Apple M1 Max
Node.js: 22.14.0
Package manager: Yarn version: 4.0.1

Works when running eslint from Terminal outside VS Code but doesn't work inside VS Code. (Also seems to work well in other IDEs like Cursor)

VS Code information:
Version: 1.99.3 (Universal)
Commit: 17baf841131aa23349f217ca7c570c76ee87b957
Date: 2025-04-15T23:18:46.076Z (3 wks ago)
Electron: 34.3.2
ElectronBuildId: 11161073
Chromium: 132.0.6834.210
Node.js: 20.18.3
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.3.0

Probable reason of failure:
The eslint-import-resolver-typescript v4+ depends on unrs-resolver, which includes native bindings. Native bindings are compiled for a specific Node version and architecture. So:

When you install dependencies, Yarn uses your terminal Node version (v22, x86_64).

But VS Code runs ESLint using its bundled Node (v20, arm64).

So the native module is not compatible with VS Code’s runtime.

This mismatch leads to the Failed to load native binding error only in VS Code, even though things work in the terminal.

@JounQin
Copy link
Collaborator

JounQin commented May 7, 2025

I'm not sure to understand why there are two arches between your terminal and VSCode?

That's said, can you:

  1. try to set eslint.runtime: node: https://github.com/microsoft/vscode-eslint#:~:text=is%20false.-,eslint.runtime,-%2D%20use%20this%20setting
  2. It seems like same of Error unable to resolve path to module. eslint import/no-unresolved but only in VSCode, not in ESLint CLI microsoft/vscode-eslint#1994, can you help to confirm if it only happens on VSCode?

@valleywood
Copy link
Author

Thanks @JounQin for a your quick reply!

I can verify that setting "eslint.runtime": "node" in .vscode/settings.json actually works! 🎉
I can confirm that this only happens on VSCode (No errors in Fish/Bash terminal or in Cursor IDE)

@JounQin
Copy link
Collaborator

JounQin commented May 7, 2025

@valleywood Thanks for verification, I'll close this one then because it's out of scope.

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants