Unable to run JS migration script

Hi,

I’m following the migration guide (Realm Legacy Migration Guide - Realm Legacy Migration Guide) and trying to run the migration script.
When running I get the following error:

Error: dlopen(/Users/user/Developer/myapp/node_modules/realm/compiled/napi-v4_darwin_arm64/realm.node, 1): Symbol not found: __ZN5realm13BPlusTreeLeaf12bptree_eraseEmNS_4util11FunctionRefIFmPNS_13BPlusTreeNodeEmEEE
  Referenced from: /Users/user/Developer/myapp/node_modules/realm/compiled/napi-v4_darwin_arm64/realm.node
  Expected in: flat namespace
 in /Users/user/Developer/myapp/node_modules/realm/compiled/napi-v4_darwin_arm64/realm.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at getRealmConstructor (/Users/user/Developer/myapp/node_modules/realm/lib/index.js:96:20)
    at Object.<anonymous> (/Users/user/Developer/myapp/node_modules/realm/lib/index.js:120:26)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)

Any idea?

What version of realm are you using?

The documentation lists:

nvm use 12
npm install realm@6.1.4
npm install mongodb
node copyToMongo.js

and so the version is 6.1.4.

I tried copying the script again from the website. Using sublime editor, I noticed it shows “​​​<0x200b>” characters in all line breaks. That caused “SyntaxError: Invalid or unexpected token” when running it.
When deleting these characters and running I get:
Error: Cannot find module ‘/Users/user/Developer/myapp/node_modules/realm/compiled/napi-v4_darwin_x64/realm.node’

Are you on a M1 mac? I don’t believe we support that yet for RealmJS - or at least we didn’t for version 6.1.4

Thanks! finally some progress…
Now I have this error:

{
  type: 'https://docs.realm.io/server/troubleshoot/errors#invalid-parameters',
  title: 'Your request parameters did not validate.',
  status: 400,
  code: 601,
  invalid_params: [
  {
  name: 'path',
  reason: "The path '/' (decoded: '/') is invalid: encountered an invalid segment: ''. Error: segment is empty"
  }
 ]
}

Looks like the path is invalid. How can I know for sure what’s the correct path?

looks like your realm path is invalid. possibly because of an extra / - double check your configuration variables

Hi,

Thanks. I changed my path from “myapp” to “/myapp”. And now, the error is:

type: 'https://docs.realm.io/server/troubleshoot/errors#access-denied',
title: 'The path is invalid or current user has no access.',
status: 403,
detail: "A non-admin user is not allowed to create realms outside their home folder. 
UserId:    '6be4ad56cbb042082b0ac0ecc83b462d'. RealmPath: '/myapp'",
code: 614

What am I doing wrong now?

Any idea what I am missing? How can I debug this?