realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Realm.open function fails w/ **No Suitable Image found** error on NodeJS

Open Karl-EdwardFPJeanMehu opened this issue 2 years ago • 6 comments

How frequently does the bug occur?

All the time

Description

I was expecting to be able open a realm for my data models to query.

Stacktrace & log output

.yarn/cache/bindings-npm-1.5.0-77ce1d213c-65b6b48095.zip/node_modules/bindings/bindings.js:112:48
 ❯ getRealmConstructor .yarn/unplugged/realm-virtual-606e3ba05e/node_modules/realm/lib/index.js:28:37
     26|     case "node.js":
     27|     case "electron":
     28|       return nodeRequire("bindings")("realm.node").Realm;
       |                                     ^
     29|     case "reactnative":
     30|       //switch how babel transpiled code creates children objects.
 ❯ Object.<anonymous> .yarn/unplugged/realm-virtual-606e3ba05e/node_modules/realm/lib/index.js:53:26

Can you reproduce the bug?

Yes, always

Reproduction Steps

The error can be reproduced for using either partitioned or flexible synched Realms

type Dog = {
  name: string;
  age: number;
};

const DogSchema = {
  name: 'Dog',
  properties: {
    name:  'string',
    age: 'int',
  }
};

try{
    const realm = await Realm.open({
      schema: [DogSchema],
      sync: {
        user: app.currentUser?,
        partitionValue: 'Clifford',
      },
    })
} catch (e) { console.log(e) }

Version

10.19.2

What SDK flavour are you using?

Atlas Device Sync

Are you using encryption?

No, not using encryption

Platform OS and version(s)

MacOS Mojave

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

Karl-EdwardFPJeanMehu avatar Jun 24 '22 13:06 Karl-EdwardFPJeanMehu

Hi, that's strange. Can you post any more of the stack trace or is that all you get?

Can you run find . -name "realm.node" from your project directory to check that file exists? You should get output like:

./node_modules/realm/build/Release/realm.node

tomduncalf avatar Jun 24 '22 15:06 tomduncalf

Yes, The file exists. I had checked it out and its there. Here is the complete output. I'm thinking maybe the incorrect file was compiled in the lib ?


 FAIL  src/__tests__/realm.int.test.ts [ src/__tests__/realm.int.test.ts ]
Error: dlopen(/Users/****/Documents/Dev/vagrant/www/telehealth/.yarn/unplugged/realm-virtual-606e3ba05e/node_modules/realm/build/Release/realm.node, 1): no suitable image found.  Did find:
        /Users/***/Documents/Dev/vagrant/www/***/.yarn/unplugged/realm-virtual-606e3ba05e/node_modules/realm/build/Release/realm.node: cannot load 'realm.node' (load command 0x80000034 is unknown)
        /Users/***/Documents/Dev/vagrant/www/***/.yarn/unplugged/realm-virtual-606e3ba05e/node_modules/realm/build/Release/realm.node: cannot load 'realm.node' (load command 0x80000034 is unknown)
 ❯ Function.require$$0.Module._load .pnp.cjs:11692:14
 ❯ bindings .yarn/cache/bindings-npm-1.5.0-77ce1d213c-65b6b48095.zip/node_modules/bindings/bindings.js:112:48
 ❯ getRealmConstructor .yarn/unplugged/realm-virtual-606e3ba05e/node_modules/realm/lib/index.js:28:37
     26|     case "node.js":
     27|     case "electron":
     28|       return nodeRequire("bindings")("realm.node").Realm;
       |                                     ^
     29|     case "reactnative":
     30|       //switch how babel transpiled code creates children objects.
 ❯ Object.<anonymous> .yarn/unplugged/realm-virtual-606e3ba05e/node_modules/realm/lib/index.js:53:26

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
  "code": "ERR_DLOPEN_FAILED",
}

Karl-EdwardFPJeanMehu avatar Jun 24 '22 19:06 Karl-EdwardFPJeanMehu

@Karl-EdwardFPJeanMehu Just for the sake of due diligence: Have you tried cleaning node_modules?

rm -rf node_modules
npm install

One possible cause of this issue is that Node can't find an image for the correct architecture in the library it's trying to load.

fronck avatar Jun 28 '22 08:06 fronck

Yes, I've tried several times. Although I am using Yarn I even switching to NPM but the issue persists. I've also tried Node v14-18 to no avail.

Karl-EdwardFPJeanMehu avatar Jun 29 '22 08:06 Karl-EdwardFPJeanMehu

@Karl-EdwardFPJeanMehu

From your comment it looks like you are using Vagrant. I wonder if you are mixing Linux and MacOS binaries. We have seen similar issues when building for Electron. The workaround was to run touch node_modules/realm/binding.gyp.

kneth avatar Sep 16 '22 09:09 kneth

I am experiencing the same issue on version 10.21.1. Currently on Windows 11, using the Node.JS SDK, building with TSC, not using encryption, not using Realm Sync. (Also not using Vagrant)

I have rebuilt node_modules multiple times... it was working previously when I was on version 10.19.5.

My error message:

node:internal/modules/cjs/loader:1189
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The specified module could not be found.
\\?\C:\Users\{...}\node_modules\realm\build\Release\realm.node
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (C:\Users\{...}\node_modules\bindings\bindings.js:112:48)
    at getRealmConstructor (C:\Users\{...}\node_modules\realm\lib\index.js:28:37)
    at Object.<anonymous> (C:\Users\{...}\node_modules\realm\lib\index.js:53:26)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) {
  code: 'ERR_DLOPEN_FAILED'

Replaced paths with {...} for anonymity purposes

blaykelarue avatar Sep 21 '22 17:09 blaykelarue

With v10.22.0 we have fixed the broken Windows binary.

kneth avatar Oct 18 '22 14:10 kneth