Invariant Violation: Native module cannot be null. on Managed Expo

Please provide the following:

  1. SDK Version: 41.0.0
  2. Platforms(Android/iOS/web/all): Android/ios

I upgraded to SDK 41 yesterday and worked out some smaller issues before everything ran perfectly. After changing some of my backend (aws). I started receiving this error. I’m not sure where to look anymore. I went through the stack trace but in the end I am not sure I should be touching the node_modules. I have removed node_modules and ran npm i. I have attempted to downgrade Expo but that changed nothing so I upgraded back to 41. Here are my packages:

  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  "dependencies": {
    "@aws-amplify/cli": "^4.30.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "6.0.0",
    "@react-native-community/picker": "^1.8.1",
    "@react-navigation/bottom-tabs": "^5.11.10",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.4",
    "aws-amplify": "^3.3.4",
    "aws-amplify-react-native": "^4.2.7",
    "expo": "^41.0.0",
    "expo-font": "~9.1.0",
    "expo-location": "~12.0.4",
    "expo-status-bar": "~1.0.4",
    "expo-web-browser": "~9.1.0",
    "graphql": "^14.7.0",
    "lodash.debounce": "^4.0.8",
    "lottie-react-native": "3.5.0",
    "luxon": "^1.25.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "",
    "react-native-elements": "^3.0.0-alpha.1",
    "react-native-fs": "^2.16.6",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-ionicons": "^4.6.5",
    "react-native-phone-input": "^0.2.4",
    "react-native-reanimated": "~2.1.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.0.0",
    "react-native-sound": "^0.10.12",
    "react-native-vector-icons": "^7.1.0",
    "react-native-voice": "^0.2.6",
    "react-native-web": "~0.13.12",
    "react-redux": "^7.2.1",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-logger": "^3.0.6",
    "reselect": "^4.0.0",
    "sentry-expo": "^3.1.0",
    "watchman": "^1.0.0"
  "devDependencies": {
    "@babel/core": "~7.9.0"
  "private": true

and the error:

I have also included the NativeEventEmitter snippet


please try the techniques from fyi/ at main · expo/fyi · GitHub to narrow down the problem. what is the specific function call that leads to this? or what module import?

this amplify issue may possibly be related although the error message appears to be different and you seem to be using the correctly patched version: Auth.signIn throws (0, _getRandomBase.default) is not a function. (In '(0, _getRandomBase.default)(array.byteLength)', '(0, _getRandomBase.default)' is undefined) · Issue #8113 · aws-amplify/amplify-js · GitHub

Hey thanks for the quick reply. I already worked through that amplify issue with EXPO_LEGACY_IMPORTS=1 expo start This seemed to work with building bundles as well. The error occurs on load so as far as imports or function calls I havent been able to get to get that far. Expo builds just fine but crashes after finishing. I will try some of these manual debug methods. Thanks again.

i’d recommend against using EXPO_LEGACY_IMPORTS=1 generally, a better solution until you get the patched version of the library is to use patch-package to apply this fix fix(amazon-cognito-identity-js): resolve missing getRandomBase64 impl… · aws-amplify/amplify-js@2d4052d · GitHub.

1 Like

Thanks a lot! Really have been digging around trying to get this update working. The issue was most likely with aws as I rolled back into a previous commit from an old branch before the schema changes and everything was working smoothly again. I will definitely look into using the patcher instead.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.