Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invariant Violation: Module RCTDeviceEventEmitter is not a registered callable module #28801

Closed
piiih opened this issue May 1, 2020 · 17 comments
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@piiih
Copy link

piiih commented May 1, 2020

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 :/

image

React Native version:

System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) 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.

@AngeloMateus
Copy link

I'm having this issue as well

@alex521
Copy link

alex521 commented May 27, 2020

+1

1 similar comment
@ChannelJuanNews
Copy link

+1

@leonsilicon
Copy link

leonsilicon commented Jun 25, 2020

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 rerun npm install or yarn 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:

Screenshot from 2020-06-25 08-06-51

And this is what the package.json looked like:

{
  "name": "react-native-music-kit",
  "title": "React Native Music Kit",
  "version": "1.0.0",
  "description": "TODO",
  "main": "index.js",
  "files": [
    "README.md",
    "android",
    "index.js",
    "ios",
    "react-native-music-kit.podspec"
  ],
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/github_account/react-native-music-kit.git",
    "baseUrl": "https://github.com/github_account/react-native-music-kit"
  },
  "keywords": [
    "react-native"
  ],
  "author": {
    "name": "Your Name",
    "email": "yourname@email.com"
  },
  "license": "MIT",
  "licenseFilename": "LICENSE",
  "readmeFilename": "README.md",
  "peerDependencies": {
    "react": "^16.8.1",
    "react-native": ">=0.60.0-rc.0 <1.0.x"
  }
}

@gokul-t
Copy link

gokul-t commented Jul 7, 2020

I'm having this issue as well

@wballard
Copy link

wballard commented Aug 21, 2020

Same -- even from a raw npx react-native init AwesomeProject, with no code added at all.

On startup:

2020-08-21 14:05:08.332377-0500 Hence[32671:356062] [javascript] Invariant Violation: Module RCTLog is not a registered callable module (calling logIfNoNativeHook)
2020-08-21 14:05:08.335338-0500 Hence[32671:356062] [javascript] Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
2020-08-21 14:05:08.336524-0500 Hence[32671:356062] [javascript] Invariant Violation: Module RCTDeviceEventEmitter is not a registered callable module (calling emit)

@wballard
Copy link

wballard commented Aug 22, 2020

If it helps anyone:

metro.config.js

const path = require("path");
const watchFolders = [
  //Relative path to packages directory because I'm in yarn workpspaces
  path.resolve(__dirname + "/../.."),
];
module.exports = {
  resolver: {
    extraNodeModules: {},
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        // this defeats the RCTDeviceEventEmitter is not a registered callable module
        inlineRequires: true,
      },
    }),
  },
  watchFolders,
};
react-native start --reset-cache

@safaiyeh safaiyeh added Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Needs: Triage 🔍 labels Aug 23, 2020
@github-actions
Copy link

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

@safaiyeh
Copy link
Contributor

Hi @piiih thank you for the issue. Could you provide a repro that consistently demonstrates this error?

@DeepRolling
Copy link

I have same issue , in my condition , it cause by i update my node version .
solution : delete all node_modules which already downloaded ,and run "yarn install" command for re-install them .
then they will be work .

shhong7757 added a commit to Type-Any/react-native-clear-cache that referenced this issue Sep 25, 2020
1. fix metro.config.js
error Invariant Violation: Module RCTDeviceEventEmitter is ...
change value of inlineRequires false to true
about link: facebook/react-native#28801 (comment)
@luatnd
Copy link

luatnd commented Oct 29, 2020

I have same issue:

Invariant Violation: Module RCTLog is not a registered callable module (calling logIfNoNativeHook)

It only occur on remote debugging mode, if you disable remote debugging in dev mode, it's still work

@michaelgmcd
Copy link
Contributor

Make sure you have one version of react-native installed. npm ls react-native should help.

tivjoe pushed a commit to tivjoe/react-native-sparrow-album that referenced this issue Jan 17, 2021
@cristiangu
Copy link

cristiangu commented Aug 12, 2021

If it helps anyone:

metro.config.js

const path = require("path");
const watchFolders = [
  //Relative path to packages directory because I'm in yarn workpspaces
  path.resolve(__dirname + "/../.."),
];
module.exports = {
  resolver: {
    extraNodeModules: {},
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        // this defeats the RCTDeviceEventEmitter is not a registered callable module
        inlineRequires: true,
      },
    }),
  },
  watchFolders,
};
react-native start --reset-cache

This helped me to fix it!

@wballard, many many many thanks! 🙏🙏🙏

@arled
Copy link

arled commented Sep 17, 2022

Surely this cannot be the fix right?

@zfoltin
Copy link

zfoltin commented Dec 6, 2022

I couldn't believe it myself either but changing inlineRequires: false to true 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
image

@github-actions
Copy link

github-actions bot commented Mar 9, 2023

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 9, 2023
@github-actions
Copy link

This issue was closed because the author hasn't provided the requested feedback after 7 days.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests