Skip to content

Resolve error: Failed to load native binding #446

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
almunnings opened this issue May 3, 2025 · 4 comments
Closed

Resolve error: Failed to load native binding #446

almunnings opened this issue May 3, 2025 · 4 comments

Comments

@almunnings
Copy link

Since upgrading past 3.8.7 the native binding has broken our workflow.

We use a container to install node and node dependencies and compile code, and then the local vscode does the linting locally.

Forgive me I am not an expert in eslint or node.

Container = linux node 20
Host = macos with vscode

Resolve error: Failed to load native binding
    at Object.<anonymous> (/Users/al/Sites/REDACTED/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/al/Sites/REDACTED/node_modules/eslint-import-resolver-typescript/lib/index.cjs:8:20)

With @typescript-eslint/parser and projectService: true - this tool chain is now unusable. We are unable to lint code and have it installed in a controlled environment.

I attempted the suggested workarounds of NAPI_RS_FORCE_WASI=true yarn add @unrs/resolver-binding-wasm32-wasi but that won't install on an arm64 processor.

error @unrs/resolver-binding-wasm32-wasi@1.7.2: The CPU architecture "arm64" is incompatible with this module.

Our only solution is to downgrade to 3.8.7 to avoid interruption.

Is there a solution out there for me to compile within a container and lint locally? (I'd think this is fairly common practice for some websites.)

I'd need a way to optionally choose to not use the urns/resolver binary, or to optionally choose a binary based on some other factor. Or ideally a fallback is available somehow if the binary is unusable?

@JounQin
Copy link
Collaborator

JounQin commented May 3, 2025

https://yarnpkg.com/configuration/yarnrc?#supportedArchitectures

yarn config set supportedArchitectures.cpu "wasm32"
yarn add -D @unrs/resolver-binding-wasm32-wasi
yarn config remove supportedArchitectures.cpu

https://antfu.me/posts/why-reproductions-are-required

@SukkaW
Copy link
Collaborator

SukkaW commented May 3, 2025

https://antfu.me/posts/why-reproductions-are-required

@JounQin It is probably the fault of both yarn and napi-rs, not providing enough information.

Yarn should automatically detect the current system architecture and provide a warning where no suitable optional dependency was installed.

napi-rs, on the other hand, should provide the current arch of the system, the variants already installed, and what is missing, in the error message (or Error#cause).

@almunnings
Copy link
Author

Thank you for the prompt reply!
Your suggestion set me on the correct course.

I had to upgrade from Yarn 1.x to 4.x (with corepack), and then have the following .yarnrc file

nodeLinker: node-modules

supportedArchitectures:
  os:
    - current
    - darwin

This then behaves nicely with the .eslintrc.cjs settings I have, as the container in docker installs both binaries

  • node_modules/@urns/resolver-binding-darwin-arm64
  • node_modules/@urns/resolver-binding-linux-arm64-musl

And now vscode is working again and linting happily.

Thank you

@JounQin
Copy link
Collaborator

JounQin commented May 5, 2025

Yarn should automatically detect the current system architecture and provide a warning where no suitable optional dependency was installed.

@almunnings Maybe you can help to raise an issue to https://github.com/yarnpkg/berry

napi-rs, on the other hand, should provide the current arch of the system, the variants already installed, and what is missing, in the error message (or Error#cause).

It's already there: https://github.com/unrs/unrs-resolver/blob/116035dd1b6ede33dac7236e91b0e21de837569a/napi/index.js#L372


Close as out of scope for now.

@JounQin JounQin closed this as completed May 5, 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

3 participants