node ODBC install for NWjs on Windows fails

456 views Asked by At

I'm using nodejs and node webkit for a windows app (node-webkit is now NWjs).

I installed the node-odbc module and used the included tests to see if it works. Testing the database connection worked fine via the command line ("node aTestFile.js"), but the moment I try to call it from within index.html inside node-webkit, I receive the following error:

Uncaught node.js Error 

Error: A dynamic link library (DLL) initialization routine failed. 
c:\Users\SomeUser\Documents\Development\accessingDB\node_modules\odbc\build\Release\odbc_bindings.node
    at Error (native)

And if I try to add the file as the node-main in the package.json, nothing happens.

I need a little help. What am I doing wrong?

1

There are 1 answers

0
jimmont On

as noted in the docs for NWjs (previously node-webkit), I found the following solution worked on Windows 10 when using an LTS release:

  1. preliminary install for Windows node_modules, first install Nodejs from nodejs.org and then: npm i -g windows-build-tools node-gyp and be sure to enable showing file extensions in explorer (so the next step has file extension '.cc')
  2. replace file win_delay_load_hook.cc at path C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src from GitHub source https://github.com/nwjs/nw.js/blob/nw18/tools/win_delay_load_hook.cc
  3. now proceed as usual npm install

for non-LTS releases or more help refer to the official docs: http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/