Windows 10 electron example app onnxruntime_binding.node not found
System Info
transformers.js: ^2.6.2 Using the example app here https://github.com/xenova/transformers.js/tree/main/examples/electron Tried both node 18 & 20 on fresh windows 10 home bootcamp install on an intel mac.
Environment/Platform
- [ ] Website/web-app
- [ ] Browser extension
- [ ] Server-side (e.g., Node.js, Deno, Bun)
- [X] Desktop app (e.g., Electron)
- [ ] Other (e.g., VSCode extension)
Description
\\?\C:\Users\samto\Desktop\transformers.js\examples\electron\node_modules\onnxruntime-node\bin\napi-v3\win32\x64\onnxruntime_binding.node
at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1869)
at Module._extensions..node (node:internal/modules/cjs/loader:1326:18)
at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1869)
at Module.load (node:internal/modules/cjs/loader:1096:32)
at Module._load (node:internal/modules/cjs/loader:937:12)
at f._load (node:electron/js2c/asar_bundle:2:13377)
at Module.require (node:internal/modules/cjs/loader:1120:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\samto\Desktop\transformers.js\examples\electron\node_modules\onnxruntime-node\dist\binding.js:9:1)
at Module._compile (node:internal/modules/cjs/loader:1241:14) {
code: 'ERR_DLOPEN_FAILED'
}
Reproduction
On Windows 10 Home:
- git clone https://github.com/xenova/transformers.js/tree/main/examples/electron
- cd transformers.js\examples\electron
- npm i
- npm run start
- enter something in the text box that appears on screen
Just tested this same flow on a mac and it works fine... Thanks in advance for any help!
fresh windows 10 home bootcamp install on an intel mac
I would assume this is the issue, and might have something to do with how onnxruntime-node selects which .node file to load depending on the underlying hardware.
cc @fs-eire @guschmue, any ideas?
Interesting. I did some research and ran some very basic onnxruntime-node code within the same electron app and the same error occurs so I don't think this is related to transformers.js. Will keep the issue open for now in case there are any other ideas.
I believe I'm running into the same issue. (edit, might not be the same issue, didn't realize the original was cloning sample directly. Might leave this here anyway as it's been one helluva rabbit hole and hopefully it helps someone regardless)
If you use the electron-forge webpack template, it has troubles loading (some) native node modules, and it's default config seems to break something (?) in transformers.js
I adapted the default electron template here to work with webpack/typescript: https://github.com/FrozenKiwi/transformers-test. The last 2 commits should give a pretty good idea of what you need to do in your own project to enable this very cool package. But in short:
- set
externals: [ 'onnxruntime-node', 'sharp', ],on your main webpack config - Disable the
asarpackaging and associated@electron-forge/plugin-auto-unpack-nativesplugin - Use
@timfish/forge-externals-pluginto ensure that the native modules are included by webpack
After this, when you make/install, you should see in your packages in <AppData>/local/app.../resources/app/node_module, and running the app works similar to the provided template