nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.34k stars 3.88k forks source link

Uncaught node.js Error - no suitable image found ... Did find ... but wrong architecture #2508

Closed hems closed 9 years ago

hems commented 9 years ago

i just have this on my index.hmtl:

level = require( "level")

i have "level" on my package.json and executed "npm install" on my osx

Error: dlopen(/Users/hems/git/oceanelevent/WHDApp/app/app/node_modules/leveldown/build/Release/leveldown.node, 1): no suitable image found.  Did find:
/Users/hems/git/oceanelevent/WHDApp/app/app/node_modules/leveldown/build/Release/leveldown.node: mach-o, but wrong architecture
    at Error (native)
    at Module.load (module.js:354:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at bindings (/Users/hems/git/oceanelevent/WHDApp/app/app/node_modules/leveldown/node_modules/bindings/bindings.js:76:44)
    at Object.<anonymous> (/Users/hems/git/oceanelevent/WHDApp/app/app/node_modules/leveldown/index.js:1:99)
    at Module._compile (module.js:454:26)
    at Object.Module._extensions..js (module.js:472:10)
    at Module.load (module.js:354:32)

Tested with resources/node-webkit-v0.10.5-osx-ia32

hems commented 9 years ago

I just tried with node-webkit-v0.8.6-osx-ia32 and it worked!

hems commented 9 years ago

shall i close the issue?

rogerwang commented 9 years ago

looks like you're compiling it against node v0.10, which node-webkit 0.8.x is based on.

hems commented 9 years ago

I still did not manage to solve this.. i'm trying

nw-gyp rebuild --target=0.10.0

on my node_modules/leveldown folder...

hems commented 9 years ago

I get the error even with 0.8.x : (

ahizzle commented 9 years ago

@hems what about with node-webkit 0.9.2?

hems commented 9 years ago

@ahizzle i'll try it again ( and do better reports ) tonight, latest in the next couple of days.

i'm trying to use level db, so basically in order to reproduce, just need to

npm install level --save

then require level on your app

require( "level" )

I think level is an amazing database and would be nice to have some instructions on how to use it with node-webkit.

I'm willing to help definitely.

Also i remember there is a embedded database on the WIKI which "is based no level" but i did not check if it uses level under the hood or if it's just the implementation that is based on.

anyway i'll be back here with more input quite soon.

thank you

hems commented 9 years ago

@ahizzle with 0.9.2 i get exactly the same error

hems commented 9 years ago

@rogerwang with 0.8.5 i got exactly same error as well. perhaps i'm not doing the nw-gyp thing correctly.

hems commented 9 years ago

@rogerwang / @ahizzle after going to leveldown and doing nw-gyp rebuild --target=0.8.6 i get

Error: module did not self-register

for leveldown

hems commented 9 years ago

sorry for spamming you guys. hope to solve this puzzle soon.

hems commented 9 years ago

Here is my pastebin with the errors for: nw-gyp rebuild --target=0.10.5

http://pastebin.com/bRMsm9hU

hems commented 9 years ago

Here is my pastebin with errors for: nw-gyp rebuild --target=0.11.0 http://pastebin.com/GdKWMGe2

hems commented 9 years ago

So basically i'm stuck with not being able to compile with target=0.11.0 and target=0.10.5

When compiling to 0.8.6 i get the "Module did not self-register" error when launching my app with require( "level") on my index page.

ahizzle commented 9 years ago

@hems looks like the problem is actually in the nan module, which is a leveldown dependency. i can build successfully using leveldown 0.10.2, but not 1.0.0. after building i can require('level') and it seems to work...

hems commented 9 years ago

@ahizzle so basically you reverted to use a previous version of "level" which have nan version 0.10.2 as dependency ?

Did you check the console ( @ Developer tools? ) sometimes i managed to make the app run, but the error would be thrown in the console instead of redirecting the user to the error page.

By the way, do you think would make sense to open an issue @ nan repository and try to get that sorted?

ahizzle commented 9 years ago

@hems yep and yep. it works. it looks like the nan issue is related to an API mismatch with the underlying V8 version. could be that a newer version of nan already addresses that, but then you'd have to see whether the latest leveldown would work w/ the latest nan, etc.

drschwabe commented 9 years ago

Similar error here, but attempting to require the latest PouchDB - which has leveldown as a dependency.

Error: Module did not self-register.
    at Error (native)
    at Module.load (module.js:354:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at bindings (C:\dev\myapp\node_modules\pouchdb\node_modules\leveldown\node_modules\bindings\bindings.js:76:44)
    at Object.<anonymous> (C:\dev\myapp\node_modules\pouchdb\node_modules\leveldown\index.js:1:99)
    at Module._compile (module.js:454:26)
    at Object.Module._extensions..js (module.js:472:10)
    at Module.load (module.js:354:32)
hems commented 9 years ago

@mrschwabe check @ahizzle comment, let me know if you figure that out. i still did not : (

agnat commented 9 years ago

The first error Error: dlopen(...) no suitable image found ... is caused by an architecture mismatch. Node-webkit is a 32 bit executable while the add-on is 64 bit. To verify this run:

file `which node-webkit`
file $PATH_TO_ADDON

This happens on mac os only since only mac os supports universal binaries. To fix this just build the add-on as a universal binary by adding:

  , 'conditions': [
    [ 'OS=="mac"',
      { 'xcode_settings':
        { 'OTHER_CPLUSPLUSFLAGS': ['-arch i386', '-arch x86_64']
        , 'OTHER_LDFLAGS': ['-arch i386', '-arch x86_64']
        }
      }
    ]]

A good place to do that might be addon.gypi in nw-gyp (target_defaults section). Note, that if node-webkit is always 32 bit (why?) you could just pin it down to -arch i386...

The other issue Error: Module did not self-register pops up when loading an old add-on (build with pre 0.11) on a newer node version.

HTH

hems commented 9 years ago

@agnat uhn..

thank you for getting back to us, regarding your comment that node-webkit is 32bits, that is not always true...

For instance the binary i'm using is 64 bits

Contents/MacOS [ file node-webkit                                                                                                                    clean * ] 12:58 am
node-webkit: Mach-O 64-bit executable x86_64
hems commented 9 years ago

@agnat i tried to follow your instructions and have "level" running inside of node-webkit latest version and it did not work..

would you mind having a go with

npm install --save level

and then importing level in your node-webkit app?

level = require( "level" )

the error i get is "module could not self register, but that happens on level/node_modules/leveldown

hems commented 9 years ago

@agnat here is the console output i got when trying to

 nw-gyp configure --target=0.11.2    
 nw-gyp build

Also created an issue @leveldown repository hoping someone there might be able to help us: https://github.com/rvagg/node-leveldown/issues/138

agnat commented 9 years ago

[...] might be able to help us

Hehe... us? What do you mean: us? ;-)

Looking at the compile error it looks like your system is pretty messed up. Until now we had:

I'd say you have too many different (node) versions in different places... You might want to clean that up... and I mean really. Also look for stall node/v8 header files in system folders (/usr/include /usr/local/include).

I'd also make a habit of using:

nw-gyp rebuild --target=0.11.2

Good luck!

hems commented 9 years ago

by "us" i mean everyone with this issue...

regarding multiple node versions, i'll make a fresh install and see if something changes.

cheers

y-lohse commented 9 years ago

@hems: I had the same no suitable image found ... Did find ... but wrong architecture error using the mdns package instead of level, switching to 64bit osx version of node webkit solved the problem for me.

I tried installing level to see how it goes and am also unable to recompile leveldown using nw-gyp, with similar error to yours. However I'd really say this is a leveldown / nan specific issue.

hems commented 9 years ago

@y-lohse thank you for the heads up