React-native: [0.57] _this._registerEvents is not a function on a clean project

Created on 13 Sep 2018  路  25Comments  路  Source: facebook/react-native

Environment

$ react-native info

  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 520.12 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
    IDEs:
      Xcode: 10.0/10L232m - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0 
      react-native: 0.57.0 => 0.57.0 
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1

Description

Bumped an existing 0.56.1 project to 0.57 and encountered an error on simulator start: _this._registerEvents is not a function on a clean project. Tried a new project from scratch and got the same error. Running Xcode 10 Beta.

Same error was mentioned in the following ticket: #20712

screen shot 2018-09-13 at 12 21 14

_this._registerEvents is not a function. (In '_this._registerEvents()', '_this._registerEvents' is undefined)

WebSocket
    index.bundle?platform=ios&dev=true&minify=false:24147:28
connectToDevTools
    index.bundle?platform=ios&dev=true&minify=false:26078:62
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:25863:38
loadModuleImplementation
    index.bundle?platform=ios&dev=true&minify=false:262:14
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:19771:20
loadModuleImplementation
    index.bundle?platform=ios&dev=true&minify=false:262:14
guardedLoadModule
    index.bundle?platform=ios&dev=true&minify=false:150:47
global code
    index.bundle?platform=ios&dev=true&minify=false:81797:4
****

Reproducible Demo

xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
react-native init AwesomeProject
cd AwesomeProject
node_modules/.bin/react-native run-ios

EDIT: Tried another new project and it worked this time. I guess it must be related to caching issues.

Will reopen if I can reliably reproduce.

Locked

Most helpful comment

20567 by kelset

  1. add the metro-react-native-babel-preset package
  2. change .babelrc to
    {
    "presets": ["module:metro-react-native-babel-preset"]
    }
  3. npm run start --reset-cache
    or
    react-native start -reset-cache

All 25 comments

got the same issue.

I got this issue on a clean new project as well. Currently I need to fallback to 0.56.0 to continue

20567 by kelset

  1. add the metro-react-native-babel-preset package
  2. change .babelrc to
    {
    "presets": ["module:metro-react-native-babel-preset"]
    }
  3. npm run start --reset-cache
    or
    react-native start -reset-cache

react-native start --reset-cache worked for me on @hbicexp solution

Same error..

We updated to React Native 0.57.4 and @babel/core 7.1.2 and our problem went away.

Updating to React Native 0.57.4 and @babel/core 7.1.2 did not solve it for me.

Clean install doing nothing but react-native init RNTestProject produces this same error for me still.

still a problem

having the same issue after changing to apollo client 2.0

same error
_20181218155733

Any solution for this issue? Nothing work for me :/

it has been 1,5 year that I am coding with react-native. what i learned in this long time.

  1. dont touch your released code
  2. never mind doing something new

'cause all I have is these fc.g bugs with no solution.

Did anyone found a solution for this? I am facing the issue for a while now! Cant make new projects cause they show the same error.. :/

@ShooterArk my react-native version is "0.58.4". The following steps fix my issue:

  1. Delete the app, and use the clean the builder folder on Xcode.
  2. Close Metro Bundler and use the Xcode to rebuild the app,
  3. If still not working, try to run react-native start -reset-cache or yarn start -reset-cache -> yarn start then reload the app on client side.

Hope this can fix your issue

@HuanDay I need to execute it on Android emulator!! I have already tried multiple times: react-native start -- --reset-cache.

my react-native version is "0.59.4" and have same issue

Try commenting out setupDevtools in setUpDeveloperTools. I still haven't found the underlying issue, but since all I want to upgrade my old project, I will postpone the investigation.

Why is this closed when the referred post has no solution apart saying to piss off and create a new project? I spent entire weekend trying to upgrade some libraries and its been a nightmare.. What a waste of time..

Now finally my project builds up and starts, but upon starting I have this issue as well.. I probably going to give up and just use ancient configs.. At least it works rather than stay up to date and have a pile of errors

After following @hbicexp 's instructions I had to restart my system to get it working/truly clear the cache(was still getting errors otherwise)

I had the same problem. I did the following and now it works fine:

  1. watchman watch-del-all
  2. rm -rf node_modules/.cache
  3. react-native start --reset-cache
  4. To be absolutely sure:
    a. Uninstall the app from emulator/device.
    b. Restart the system

Never mind. The problem was fixed but after about 30 mins it's back and this time the above solution is not working.
I even tried gradlew clean and npm cache clean.

Update:
I removed everything from .babelrc and left an empty object and now the app works perfectly.
Even after ~1.8 years of development in react-native, I have no idea about what is going on. :\

Facing the same issue.

Requiring module "node_modules/react-native/Libraries/Core/InitializeCore.js", which threw an exception: TypeError: _this._registerEvents is not a function

Tried all the methods mentioned above. This is the output of my react-native info

  React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
      CPU: (4) x64 Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
      Memory: 330.08 MB / 7.69 GB
      Shell: 4.4.19 - /bin/bash
    Binaries:
      Node: 8.3.0 - ~/.nvm/versions/node/v8.3.0/bin/node
      npm: 5.3.0 - ~/.nvm/versions/node/v8.3.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        API Levels: 23, 25, 26, 27, 28
        Build Tools: 23.0.1, 24.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3
        System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64
    npmPackages:
      react: ^16.8.3 => 16.8.6 
      react-native: ^0.59.10 => 0.59.10 

package.json

{
  "name": "testApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "react-devtools": "react-devtools"
  },
  "rnpm": {
    "assets": [
      "./App/assets/fonts"
    ]
  },
  "dependencies": {
    "adm-zip": "^0.4.11",
    "axios": "^0.17.0",
    "bugsnag-react-native": "^2.22.0",
    "clevertap-react-native": "^0.3.0",
    "js-file-download": "^0.4.1",
    "json5": "^2.1.0",
    "lodash": "^4.17.11",
    "moment": "^2.22.2",
    "native-base": "^2.7.2",
    "plist": "^3.0.1",
    "prop-types": "^15.7.2",
    "query-string": "^6.1.0",
    "react": "^16.8.3",
    "react-file-download": "^0.3.5",
    "react-moment": "^0.6.9",
    "react-native": "^0.59.10",
    "react-native-appsflyer": "1.2.13",
    "react-native-blur": "^3.2.2",
    "react-native-check-box": "^2.1.3",
    "react-native-checkbox": "^2.0.0",
    "react-native-code-push": "^5.6.0",
    "react-native-contacts": "^4.0.0",
    "react-native-cookies": "^3.3.0",
    "react-native-datepicker": "^1.7.2",
    "react-native-document-picker": "^2.1.0",
    "react-native-easy-grid": "^0.2.0",
    "react-native-email-link": "^1.1.0",
    "react-native-exception-handler": "^2.9.0",
    "react-native-extended-stylesheet": "^0.6.0",
    "react-native-fbsdk": "0.8.0",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-firebase": "^5.5.4",
    "react-native-flash-message": "^0.1.11",
    "react-native-google-signin": "^1.0.0-rc6",
    "react-native-htmlview": "^0.13.0",
    "react-native-icon-badge": "^1.1.3",
    "react-native-image-gallery": "^2.1.5",
    "react-native-image-picker": "^0.26.10",
    "react-native-image-preview": "^0.3.1",
    "react-native-image-zoom-viewer": "^2.2.15",
    "react-native-intercom": "^12.0.0",
    "react-native-linear-gradient": "2.4.0",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-mixpanel": "^1.1.1",
    "react-native-modal": "^6.5.0",
    "react-native-modal-selector": "^1.0.3",
    "react-native-modalbox": "^1.6.0",
    "react-native-month-selector": "^1.4.0",
    "react-native-picker-select": "^4.4.0",
    "react-native-prefix-picker": "^2.0.2",
    "react-native-progress": "^3.5.0",
    "react-native-prompt-android": "^0.3.4",
    "react-native-referrer": "^0.1.4",
    "react-native-restart": "0.0.6",
    "react-native-share": "^1.1.3",
    "react-native-signature-capture": "^0.4.9",
    "react-native-simple-radio-button": "^2.7.2",
    "react-native-slider": "^0.11.0",
    "react-native-star-rating": "^1.0.9",
    "react-native-svg": "^5.5.1",
    "react-native-svg-charts": "^2.2.3",
    "react-native-swiper": "^1.5.13",
    "react-native-switch": "^1.5.0",
    "react-native-theme": "^0.1.8",
    "react-native-timer-countdown": "^4.0.5",
    "react-native-vector-icons": "^4.6.0",
    "react-native-version-number": "^0.3.4",
    "react-navigation": "^1.5.13",
    "rn-fetch-blob": "^0.10.13",
    "rn-tooltip": "^1.1.2",
    "victory-native": "^0.15.0",
    "xcode": "^1.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.5.4",
    "@babel/runtime": "^7.5.4",
    "babel-jest": "20.0.3",
    "babel-loader": "^8.0.6",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "babel-preset-react-native": "^5.0.2",
    "jest": "20.0.4",
    "metro-react-native-babel-preset": "^0.55.0",
    "react-devtools": "^3.2.3",
    "react-test-renderer": "^16.8.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

Anybody got any solution yet !!

I'm also facing this issue on version 0.60.5

Error screenshot

react-native info:

System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 1.10 GB / 7.88 GB
  Binaries:
    Node: 12.9.0 - C:\Users\GUSTAV~1.MAX\AppData\Local\Temp\yarn--1567529680393-0.3427366134530774\node.CMD
    Yarn: 1.17.3 - C:\Users\GUSTAV~1.MAX\AppData\Local\Temp\yarn--1567529680393-0.3427366134530774\yarn.CMD
    npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5791312

package.json

{
  "name": "HomeDoctor",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.1",
    "axios": "^0.19.0",
    "babel-plugin-root-import": "^6.4.1",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-dotenv": "^0.2.0",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-vector-icons": "^6.6.0",
    "react-native-xml2js": "^1.0.3",
    "react-navigation": "^3.12.1",
    "react-redux": "^7.1.1",
    "reactotron-react-native": "^3.6.5",
    "reactotron-redux": "^3.1.1",
    "reactotron-redux-saga": "^4.2.2",
    "redux": "^4.0.4",
    "redux-saga": "^1.0.5"
  },
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "@babel/runtime": "^7.5.5",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "babel-preset-react-native": "5.0.2",
    "eslint": "^6.2.2",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

babel.config.js

module.exports = {
  presets: [
    'module:metro-react-native-babel-preset',
    'module:react-native-dotenv',
    'react-native',
  ],
};

I tried:
https://github.com/facebook/react-native/issues/21094#issuecomment-422245589
https://github.com/facebook/react-native/issues/21094#issuecomment-435597536
https://github.com/facebook/react-native/issues/21094#issuecomment-504986169
None worked.

Solution:

I removed 'react-native' from my babel.config.js and added a parenthesis on the render of App.js instead of making it an object.

Changed it from:

const App = () => {
  <Provider store={store}>
    <Navigation />
  </Provider>;
};

to

const App = () => (
  <Provider store={store}>
    <Navigation />
  </Provider>
);
Was this page helpful?
0 / 5 - 0 ratings