I have a problem with createRealmContext
I imported following:
import { createRealmContext } from '@realm/react';
But when I run my app, with node app.js
I get:
import { createRealmContext } from '@realm/react';
^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@realm/react' does not provide an export named 'createRealmContext'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
Node.js v19.7.0
I tried:
import { createRealmContext } from '@realm/react';
and also
import createRealmContext from '@realm/react';
Since this is often the reason, when an exported member is not found. But not this time.
I also checked the reference which is the file: index.d.ts
and at the bottom is the export:
export { AppProvider, AuthError, AuthOperationName, AuthResult, OperationResult, OperationState, RealmProvider, UserProvider, createRealmContext, useApp, useAuth, useAuthResult, useEmailPasswordAuth, useObject, useQuery, useRealm, useUser };
So there is the export.
I deleted node_modules and run npm install
again. Multiple times.
And I also reinstalled multiple times @realm/react
and @realm
with:
npm i @realm/react
which I get from https://www.npmjs.com/package/@realm/react
and npm i realm
from https://www.npmjs.com/package/realm
The official Tutorial from https://www.mongodb.com/docs/realm/sdk/react-native/use-realm-react/ is also not working.
They say I have to install it with npm install @realm/react
which is the same, but I also tried to do this
My package.json
{
"type": "module",
"dependencies": {
"@react-native-async-storage/async-storage": "^1.18.2",
"@realm/react": "^0.6.0",
"express": "^4.18.2",
"express-ws": "^5.0.2",
"moment": "^2.29.4",
"mongodb": "^5.5.0",
"mongoose": "^7.2.0",
"path": "^0.12.7",
"react-native-uuid": "^2.0.1",
"realm": "^12.2.0",
"url": "^0.11.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"ws": "3.3.2"
}
}
I restarted the terminal and my pc and still nothing worked.
And I really don’t know what the issue is, because “missing” export is existing xO