agnat / node_mdns

mdns/zeroconf/bonjour service discovery add-on for node.js
http://agnat.github.com/node_mdns
MIT License
866 stars 143 forks source link

Problem with usage in Electron on windows #158

Open sebakerckhof opened 8 years ago

sebakerckhof commented 8 years ago

When I try to use this package in Electron on windows (maybe also other platforms, didn't test it) I get the following error:

Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Users\seba\Dropbox\pairingtool\node_modules\mdns\build\Release\dns_sd_bindings.node
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ATOM_SHELL_ASAR.js:159:20)
    at Object.Module._extensions..node (module.js:450:18)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:159:20)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (C:\Users\seba\Dropbox\pairingtool\node_modules\mdns\lib\dns_sd.js:24:20)
    at Module._compile (module.js:425:26)

Here's an example repository: https://github.com/sebakerckhof/electron-problem Just requiring the module already gives me this error ( https://github.com/sebakerckhof/electron-problem/blob/master/src/preload.js#L1 ).

y-lohse commented 8 years ago

I think it's the same issue than this one. The error message at least seems to be the same.

gabrielstuff commented 8 years ago

Not exactly :) when running in electron, you need to native compile mdns and use node-gyp to recompile it with the Atom header. So open a terminal and run : npm install -g node-gyp

Then go in your project folder, and in you node_modules/mdns folder. So you should have something like : cd c:\sources\myproject\nodes_modules\mdns

Then follow the guidelines here : https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md and run : node-gyp rebuild --target=0.35.0 --arch=x64 --dist-url=https://atom.io/download/atom-shell

And then you'll be happy !

sebakerckhof commented 8 years ago

Yeah, my bad, I upgraded to win10 and node-gyp broke. Anyway, I just did a fresh install on win7

I ran .\node_modules\.bin\electron-rebuild.cmd without issues, but if I then try to run node-gyp rebuild --target=0.36.8 --arch=x64 --dist-url=https://atom.io/download/atom-shell. I get:

gyp: binding.gyp not found (cwd: D:\barco\repositories\mvptool) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\seke\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\seke\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=0.36.8" "--arch=x64" "--dist-url=https://atom.io/download/atom-shell"
gyp ERR! cwd D:\barco\repositories\mvptool
gyp ERR! node -v v5.5.0
gyp ERR! node-gyp -v v3.3.0
gyp ERR! not ok

If I try to run the program I do get a different error, namely: , where I had it working in the past and now I get this error:

The system cannot find message text for message number 0x%1 in the message file for %2.
\\?\D:\barco\repositories\mvptool\node_modules\mdns\build\Release\dns_sd_bindings.node
 at Error (native)
    at process.module.(anonymous function) [as dlopen] (ATOM_SHELL_ASAR.js:159:20)
    at Object.Module._extensions..node (module.js:450:18)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:159:20)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (D:\barco\repositories\mvptool\node_modules\mdns\lib\dns_sd.js:32:22)
    at Module._compile (module.js:425:26)
sabrehagen commented 7 years ago

@sebakerckhof Have you tried rebuilding mdns? It's having trouble with the precompiled binary supplied in the package.

Try:

cd node_modules/mdns
node-gyp rebuild --target=1.6.2 --arch=x64 --dist-url=https://atom.io/download/atom-shell