node-odbc incompatible with Electron?
Hello, I have question. node-odbc incompatible with Electron?
Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Users\acterhd\Downloads\aeroflot\node_modules\odbc\build\Release\odbc_bindings.node
Hello! I helped someone with Electron in the past and the issue was that internally Electron was using a version of Node.js that was different from the version of Node.js that was used to build/install the odbc module.
I'd suggest that you make sure the version of Node.js you have installed on your system matches the version that is used in Electron. You may need to run console.log(process.version) in your Electron app and node --version from the command line to see where things stand.
I hope this helps.
See also: https://github.com/w1nk/node-odbc/issues/100#issuecomment-212504903
Depending on what you're doing, you can use electron-rebuild to rebuild odbc to the version of electron you have installed.
To do so:
npm install --save-dev electron-rebuild
$(npm bin)/electron-rebuild # Mac and Linux.
.\node_modules\.bin\electron-rebuild.cmd # Windows.
Because I kept forgetting to do this after doing an npm install (and to help others that downloaded the project), I added the following two scripts to package.json:
"scripts": {
"start": "electron .",
"postinstall": "electron-rebuild",
"electron-rebuild": "electron-rebuild"
},
The postinstall will automatically run after doing a npm install so after the typical install finishes you'll see a console log message with electron-rebuild and it will automatically rebuild odbc and any other native library you have to the electron version. This means that you shouldn't even have to think about running electron-rebuild going forward. 👍
To manually re-run electron-rebuild just run it with npm run electron-rebuild.
Easy-peezie, lemon-squeezie!