Reputation: 37238
I installed ffi
with npm install ffi --save-dev
I then use it in my electron app like this:
const {app, Menu, Tray, BrowserWindow} = require('electron');
const path = require('path')
const url = require('url')
const ffi = require('ffi');
console.log('ffi:', ffi);
but it throws this error, image -
Image typed out:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\UserS\MercuriuS\DocumentS\GitHub\NativeShot\src\e|ectror\\nodeimo...\binding.node
at Error (native)
at process.rnodule.(anonyrnous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at object.Module.,extensions..node (rnodule.js:583:18)
at object.rnodule.(anonyrnous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Moduleload (rnodule.js:473:32)
at tryModuIeLoad (rnodule.js:432:12)
at FunctionModuleJoad (rnodule.js:424:3)
at Modulerequire (rnodule.js:483:17)
at require (internal/modulejs:20:19)
at bindings
(C:\UserS\MercuriuS\DocumentS\GitHub\NativeShot\src\e|ectron\nodeimodules\binding...:44)
Does anyone know how to get this to work?
I am on windows so i even tried - https://github.com/nodejs/node-gyp#installation
npm install --global --production windows-build-tools
But this doesn't fix it.
Upvotes: 3
Views: 3300
Reputation: 14847
You have to rebuild ffi
for your Electron version using one of the documented approaches. An easier alternative might be to use electron-forge
which I believe takes care of rebuilding native modules for you.
Upvotes: 1