3

I have a node webkit application that uses the mdns module for publishing a Bonjour service from a Mac (with Mavericks). When I run the server code with node server.js everything works OK, but when running the node webkit application that uses the same server code I get this error:

"Uncaught Error: dlopen(/Users/me/myfolder/node_modules/mdns/build/Release/dns_sd_bindings.node, 1): no suitable image found.  Did find:
    /Users/me/myfolder/node_modules/mdns/build/Release/dns_sd_bindings.node: mach-o, but wrong architecture", source: /Users/me/myfolder/node_modules/mdns/lib/dns_sd.js (35)

Apparently when you install the mdns module with npm it's built for an x86 architecture and I need it for i386, because node-webkit is built for i386 (I found out about this by reading this thread: http://forums.macrumors.com/showthread.php?t=879780). You can verify it by running this in a terminal:

$ lipo -info /Applications/node-webkit.app/Contents/MacOS/node-webkit 
Non-fat file: /Applications/node-webkit.app/Contents/MacOS/node-webkit is architecture: i386

I found this link suggesting a solution: https://github.com/rogerwang/node-webkit/issues/296 for another module (node proxy). The suggested instructions are:

I managed to build a 32-bit version of node-proxy as follows:
I installed nw-gyp 
I ran nw-gyp configure --target=0.3.6  
I edited the generated file nodeproxy.target.mk in the build directory by replacing -arch x86_64by -arch i386 
I ran nw-gyp build

But as I'm not used to building node modules manually, while following the instructions it wasn't clear to me in which folder I should run those steps (I assumed it's in the module folder inside node_modules: a) when I install nw-gyp I don't get the nw-gyp command to use globally (I guess the -g option is missing in the instructions) b) using instead gyp configure --target=0.3.6 gives me an error saying that there is no option target c) I tried skipping the configure step (just to try) and the build command breaks with:

Could not automatically locate src directory. This isa temporary Chromium feature that will be removed. Use--depth as a workaround.

But when trying to use --depth (of course) it requires an argument, I couldn't find out what to put there.

So... how should I build the mdns module for using it with node webkit? (either the 0.8.6 version or the 0.10.0, I can adapt).

Carla
  • 195
  • 1
  • 10

1 Answers1

4

I managed to make it work.

As I had already installed the mdns module, I already had the source code of the module in the folder node_modules/mdns inside my project folder.

So these are the steps I followed to build the mdns module for the i386 architecture:

1) Install nw-gyp by running: npm install -g nw-gyp
2) Enter in the node_modules/mdns folder of your node-webkit project
3) Run nw-gyp configure --target=0.8.6 (this target is the version of the node-webkit you have installed)
4) And finally run nw-gyp build

I got a lot of warnings of deprecated functions, but it was built OK and now my node-webkit application can publish the Bonjour service successfully.

Unfortunately this is not the best solution, though, because the next person that installs the project will have to do the same after the regular npm install... But at least it's something to get it working.

Carla
  • 195
  • 1
  • 10