react-native: Invariant Violation: Module RCTDeviceEventEmitter is not a registered callable module
Description
I’m trying to create a fresh react-native
project with a fresh native module without any new code. I installed the MyLibrary
into MyApp
using yarn add file:/path/to/module
, I don’t know if it could be the problem 😕
React Native version:
System: OS: macOS Mojave 10.14.6 CPU: (12) x64 Intel® Core™ i7-8750H CPU @ 2.20GHz Memory: 452.77 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.16.3 - /usr/local/bin/node Yarn: 1.12.3 - /usr/local/bin/yarn npm: 6.14.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 22, 23, 25, 27, 28 Build Tools: 25.0.3, 26.0.2, 28.0.3 System Images: android-28 | Intel x86 Atom_64 Android NDK: 19.2.5345600 IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild Languages: Java: 1.8.0_252 - /usr/bin/javac Python: 2.7.16 - /usr/local/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.11.0 => 16.11.0 react-native: 0.62.2 => 0.62.2 npmGlobalPackages: react-native: Not Found
I’m using react-native
CLI from npx
.
Steps To Reproduce
I just did exactly what is in this guide https://reactnative.dev/docs/native-modules-setup and when I try to run my app on my phone I got the screenshot error.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 17 (2 by maintainers)
Commits related to this issue
- Add write getAppCacheSize fun in Kotlin 1. fix metro.config.js error Invariant Violation: Module RCTDeviceEventEmitter is ... change value of inlineRequires false to true about link: https://github.c... — committed to Type-Any/react-native-clear-cache by shhong7757 4 years ago
- fix https://github.com/facebook/react-native/issues/28801 — committed to tivjoe/react-native-sparrow-album by deleted user 3 years ago
If it helps anyone:
metro.config.js
I experienced this problem as well, and after a whole day of trying to fix the problem, what worked for me was removing the
devDependencies
in the package.json of MyLibrary. This would install another copy of React Native within the library’s node_modules, which seemed to cause the error above.Make sure you also remove
node_modules
and rerunnpm install
oryarn
in the directory of MyLibrary after making this change. This is what the directory structure of MyLibrary (I called it MusicKit) looked like for me after I got it working:And this is what the package.json looked like:
Make sure you have one version of react-native installed.
npm ls react-native
should help.I couldn’t believe it myself either but changing
inlineRequires: false
totrue
solved it. Also suggested by the Upgrade Helper - https://react-native-community.github.io/upgrade-helper/?from=0.62.3&to=0.69.7&package=react-native