Realm-js: Unable to resolve module './subscription'

Created on 30 Jun 2020  路  14Comments  路  Source: realm/realm-js

Goals

I am migrating from MongoDB Stitch to Realm in our React Native application. We have Realm working properly in our React dashboard app, but need to complete the cycle here. Realistically the only thing we are missing from Stitch is the ability to log in with Apple authentication. This is a huge blocker and we need to resolve the issue ASAP so we can get our app submitted to the App store.

Expected Results

Expected the app to build properly (it builds fine when not on the beta npm package, but we are missing constructors and methods here).

Actual Results

When installing Realm with npm i realm I do not have access to the Realm.App constructor. Thus, I cannot create a Realm application for our client.

When installing Realm with npm i [email protected] the application will break entirely.

error: Error: Unable to resolve module `./subscription` from `node_modules/realm/lib/browser/index.js`:

None of these files exist:
  * node_modules/realm/lib/browser/subscription(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * node_modules/realm/lib/browser/subscription/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
    at ModuleResolver.resolveDependency (/Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (/Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/node-haste/DependencyGraph.js:287:16)
    at Object.resolve (/Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/lib/transformHelpers.js:267:42)
    at /Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/DeltaBundler/traverseDependencies.js:434:31
    at Array.map (<anonymous>)
    at resolveDependencies (/Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/DeltaBundler/traverseDependencies.js:431:18)
    at /Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/Quinton/Repos/venueats-mobile/VenuEats/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)

Steps to Reproduce

The issue occurs when installing the project

Code Sample

Unfortunately, I do not have a code sample as I'm not even importing the file yet. It just fails to build the application since it is unable to resolve the module.

Version of Realm and Tooling

  • Realm JS SDK Version: 10.0.0-beta.7
  • Node or React Native: React Native - 0.62.2
  • Client OS & Version: Mac OS 15 (Big Sur Beta) - Xcode Version 11.5 (11E608c) / iOS Simulator 13.5
O-Community

Most helpful comment

As far as I can see, it's a metro bundler caching issue.
Could you please try to close your bundler, and then (depending on packager used):

yarn start --reset-cache

or

npm start -- --reset-cache

(at least this fixed the issue in my little test setup)

All 14 comments

+1 same problem here. Trying to get started with Realms and immediately hitting multiple roadblocks. Frustrating as hell right now!

+1 same problem here. Trying to get started with Realms and immediately hitting multiple roadblocks. Frustrating as hell right now!

@Twisterking what version of macOS are you on? I want to eliminate the possibility that its Big Sur related if possible.

It's definitely very interesting the Mongo dropped support for Sitch, an integration that worked really well. The only thing we are missing from Stitch is the ability to authenticate with Apple. Stitch claimed to have it, but I could never get it to work.

So now that they've dropped support for Stitch we are switching to Realm and facing issues right off the bat. Very unfortunate :(

@QuintonC
I am on macOS 10.14.6 with XCode 11.3.1. So no problems there.

Hi, could you share the steps to reproduce this since I am not able locally.

I followed this guide https://docs.mongodb.com/realm/react-native/install/
but installed the beta.7 (instead of beta.6) which did not reproduce the behavior.

cheers

Hi, could you share the steps to reproduce this since I am not able locally.

I followed this guide https://docs.mongodb.com/realm/react-native/install/
but installed the beta.7 (instead of beta.6) which did not reproduce the behavior.

cheers

Hey, sorry (just now seeing this).

We were able to get Realm installed finally. I'm going to update to .7 in hopes that it has some features that we're looking for.

We're having some issues with keeping the realm client persisting. E.g. We sign in a user and init a client we want to keep that client initialized while the application is open.

It seems any time we want to call a Realm function or make a graph call we have to init a new client.

Do you think you could provide some assistance?

This happens if you install realm ("realm": "^6.0.3") and then replace it with the sync version ("realm": "^10.0.0-beta.9").

As far as I can see, it's a metro bundler caching issue.
Could you please try to close your bundler, and then (depending on packager used):

yarn start --reset-cache

or

npm start -- --reset-cache

(at least this fixed the issue in my little test setup)

Same issue here.

@Pravinkumar2629 Also after you tried the command outlined in https://github.com/realm/realm-js/issues/3017#issuecomment-671283673?

@kneth I've tried that, but no luck!.

As subscription.js has been removed and all references in lib/browser have been removed in our v10 series, the best suggestion is to delete the app from the test device/simulator, clean all caches and rebuild.

Use this version,
"react": "16.13.1",
"react-native": "0.63.3",
"realm": "^6.1.4",

@sankar9659 By using ^6.1.4 you might be using v10.0.1 - please verify the version (check the file node_modules/realm/dependencies.list).

Was this page helpful?
0 / 5 - 0 ratings