I am working on an Electron app where I pretend to use native modules. I need ffi
and ref
as dependencies in my project. I installed the libraries via npm and rebuilt the modules with node-gyp rebuild
as suggested in documentation Using Native Node Modules. Everything compiled successfully, but when I try to require these libraries I get the following error:
Uncaught Error: Could not locate the bindings file. Tried:
→ C:\Users\Utilizador\Documents\my_app\build\binding.node
→ C:\Users\Utilizador\Documents\my_app\build\Debug\binding.node
→ C:\Users\Utilizador\Documents\my_app\build\Release\binding.node
→ C:\Users\Utilizador\Documents\my_app\out\Debug\binding.node
→ C:\Users\Utilizador\Documents\my_app\Debug\binding.node
→ C:\Users\Utilizador\Documents\my_app\out\Release\binding.node
→ C:\Users\Utilizador\Documents\my_app\Release\binding.node
→ C:\Users\Utilizador\Documents\my_app\build\default\binding.node
→ C:\Users\Utilizador\Documents\my_app\compiled\6.5.0\win32\ia32\binding.node
It is odd that the search paths do not correspond to library path, which should be pointing to node_modules
. I can't figure out what is causing this problem.
Any help will be appreciated, thank you in advance.
To rebuild native modules you'll have much better luck using electron-rebuild which will ensure that they're are being built against the version of electron you're using.
We're using ffi
and ref
with electron-rebuild and that was all that was required.