o-development / solid-authn-react-native

React Native implementations for Solid-OIDC
2 stars 1 forks source link

Unable to use library: Invariant Violation #1

Open ldealmei opened 3 years ago

ldealmei commented 3 years ago

I've tried using the library in my Expo app but importing the library causes the following errors when I try to run it on Android:

Invariant Violation: Module HMRClient is not a registered callable module (calling setup). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication).[...]

Invariant Violation: Module RCTDeviceEventEmitter is not a registered callable module (calling emit). [...]

I have the same issue when using the example repo. I used it almost as is, I just changed in the package.json:

    "react-native": "0.64.3", // instead of 0.64.2
    "solid-authn-react-native": "^1.0.0",  // instead of file:..

Any ideas as to what could be the problem?

s1gr1d commented 2 years ago

I also get those errors when using the library. Here is a screenshot of the Debugger output in Firefox:

Screenshot 2021-12-07 at 11 34 51

The first line is interesting:

isomorphic-webcrypto cannot ensure the security of some operations!
Install and configure react-native-securerandom or expo-random
If managed by Expo, run 'expo install expo-random'

This file uses isomorphic-webcrypto and this could cause problems. I installed expo-random (as suggested by the log output) but that did not solve the issue.

@ldealmei do you already found a solution? I will post something if I have any update on that.

s1gr1d commented 2 years ago

This is what worked for me:

First I checked, if I have more than one react-native version installed (with npm ls react-native).

This was my output: Screenshot 2021-12-07 at 14 35 56 I set my react-native version in the package.json from 0.64.3 to 0.66.3 so it is identical to the other versions. I also upgraded all the other react packages and typescript to the latest version.


Those are my dependencies now:

  "dependencies": {
    "expo": "43.0.3",
    "expo-status-bar": "1.1.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.66.3",
    "react-native-web": "0.17.5",
    "solid-authn-react-native": "1.0.0",
    "use-async-effect": "2.2.3",
    "expo-linking": "2.4.2",
    "expo-random": "12.0.1"
  },
  "devDependencies": {
    "@babel/core": "7.16.0",
    "@types/react": "17.0.37",
    "@types/react-native": "0.66.8",
    "typescript": "4.5.2"
  },

When I run npm ls react-native again, I now have only one version (0.66.3) installed and my app runs without problems 🎉