question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invariant Violation: Native module cannot be null.

See original GitHub issue

Hi, I have a problem with upgrading react-native from 0.59.10 to 0.61.5 with NativeModules.

We have our own native modules. In 0.59.10 version there was no issue with that. After upgrade to 0.61.5, I have this issue.

React Native version:

System:
    OS: macOS 10.15.2
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 527.22 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 11.5.0 - /usr/local/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 27, 28, 29
      Build Tools: 28.0.3, 29.0.0, 29.0.1, 29.0.2
      System Images: android-26 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
    react-native: 0.61.5

Steps To Reproduce

[skip]

Simulator Screen Shot - iPhone 8 - 2020-01-03 at 13 26 00

Thank you.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TheSaviorcommented, Jan 27, 2020

The problem isn’t converting from require to import, it’s converting from trying to require the file directly, vs requiring it from the react-native package.

I agree this could, and should be better documented to make this migration more clear.

It looks like this info was mentioned in a blog post in June 2019: Screen Shot 2020-01-26 at 10 11 43 PM

This probably should have been mentioned in a changelog with some code snippets though, not just this community update.

1reaction
khat33bcommented, Jan 22, 2020

@kelset @mikehardy Thanks for the quick response. I read the links which you had sent and we had already done that. The problem which I am facing is that NativeModules itself from react-native is not being resolved, not the custom module which I made. This is happening when upgrading from 0.60.6 to 0.61.0 in both Android and iOS.

I am getting this error: Error: Unable to resolve module NativeModules from src/utility/Utility.js: NativeModules could not be found within the project.

I shall make a sample project which mimics the behaviour and link it here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Native module cannot be null #43 - GitHub
At iOS, it builds successfully, however, when the app starts, I get this error: Invariant Violation: Native module cannot be null.
Read more >
(React Native - Invariant Violation: Native module cannot be null
This module (aws-amplify@unstable) introduced an error saying TypeError: undefined is not an object (evaluating '_core.Amplify.register') so ...
Read more >
Invariant Violation: Native module cannot be null. on Managed ...
SDK Version: 41.0.0; Platforms(Android/iOS/web/all): Android/ios. I upgraded to SDK 41 yesterday and worked out some smaller issues before ...
Read more >
" has not been registered" and "Invariant Violation: Native ...
I am working on a project in React Native using Expo and Firebase. ... and "Invariant Violation: Native module cannot be null" errors ......
Read more >
Error Running mobile-preview "Invariant Violation: Native ...
Hello, trying to setup the mobile-preview app for component dev. Just trying to run the app in Xcode at this point, not loading...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found