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

undefined is not a function(evaluating '_this.registerEvents()') #20791

Closed
ericcumbee opened this issue Aug 22, 2018 · 47 comments
Closed

undefined is not a function(evaluating '_this.registerEvents()') #20791

ericcumbee opened this issue Aug 22, 2018 · 47 comments
Labels
Platform: Android Android applications. Platform: Windows Building on Windows. Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.

Comments

@ericcumbee
Copy link

Environment

React Native Environment Info:
    System:
      OS: Windows 10
      CPU: x64 Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
      Memory: 757.11 MB / 7.93 GB
    Binaries:
      Yarn: 1.9.4 - C:\Users\ecumb\AppData\Roaming\npm\yarn.CMD
      npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.1.0.0 AI-173.4907809

Description

reproerror

Reproducible Demo

Create RN project using react-native init using version 0.57.0-rc0
react-native run-android
kill the spawned bundler and relaunch using npm start to work around issue #20712

@dmead
Copy link

dmead commented Aug 22, 2018

I have this exact error.

Worth mentioning that it's because i'm on 57-rc0 to escape the acessiblity bug in 56

Also worth mentioning that I'm here because 56 is the default configuration in webstorm.

Whats a stable version of react-native I can use to learn things?

@danielgindi
Copy link
Contributor

I got this too. Replaced babel preset, deleted node_modules/.cache, nothing.

@donjo9
Copy link

donjo9 commented Aug 23, 2018

Is this still a problem with rc2 ? because i used to have this issue, but dont with rc2

React Native Environment Info:
    System:
      OS: Windows 7
      CPU: x64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
      Memory: 1.09 GB / 11.92 GB
    Binaries:
      Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.1.0 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  1.5.0.0 AI-141.2456560

@kelset kelset added Platform: Windows Building on Windows. Platform: Android Android applications. labels Aug 23, 2018
@danielgindi
Copy link
Contributor

danielgindi commented Aug 23, 2018

I do have this problem with rc2 (on macOS)

@kelset
Copy link
Contributor

kelset commented Aug 23, 2018

@danielgindi can you upload a repro? Just tested locally with the 0.57-branch (details here #20712 (comment) ) and I can't repro this issue.

@ericcumbee
Copy link
Author

rc2 produces the same results on windows

@danielgindi
Copy link
Contributor

@kelset well, creating a new project using react-native cli, then changing to 0.57.0-rc.2 and the new babel preset, results in a node_modules/react-native/index.js not found.
So I can't even get to that point where the _registerEvents is undefined.

In my own project, I tried to apply the commit for util/Config.js, then delete node_modules/.cache but that did not change anything.

@badaz
Copy link

badaz commented Aug 24, 2018

Same problem here on 0.57.0-rc.2 build for android : _registerEvents is undefined

@donjo9
Copy link

donjo9 commented Aug 24, 2018

What does the Metro instance output ?

@adam187
Copy link

adam187 commented Aug 24, 2018

Had same issue on macOS.
I resolved it with running react-native upgrade based on this https://facebook.github.io/react-native/docs/upgrading#alternative

@ericcumbee
Copy link
Author

@donjo9 no errors reported on the metro instance just

 DELTA  [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)::ffff:127.0.0.1 - - [24/Aug/2018:18:16:37 +0000] "GET /index.delta?platform=android&dev=true&minify=false&deltaBundleId=a4271ccc904b5058 HTTP/1.1" 200 69 "-" "okhttp/3.10.0"
 DELTA  [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

@danielgindi
Copy link
Contributor

Seems like rc-3 solves the issue

@tamirrab

This comment has been minimized.

@danielgindi
Copy link
Contributor

danielgindi commented Aug 25, 2018

Try deleting node_modules/.cache, and then doing react-native start --resetCache

@donjo9
Copy link

donjo9 commented Aug 25, 2018

i believe it must be some kind of caching issue, because i had the issue, but can't recreate with any of the rc, not clean install or upgrade from 0.56

@tamirrab
Copy link

@danielgindi react-native start --reset-cache doesn't work :(

And I clean all my cache.

I come from 0.56 version

@danielgindi
Copy link
Contributor

@tamirrab Maybe it's time to get drastic.

  1. Make sure the you put rc.3 in your package.json
  2. Delete package-lock.json
  3. Delete node_modules
  4. npm i
  5. react-native start --reset-cache

@tamirrab
Copy link

tamirrab commented Aug 26, 2018

Did it all
plus deleted my app on the emulator

unfortunately the same error :(

@tamirrab
Copy link

tamirrab commented Aug 26, 2018

steps that i done:
watchman watch-del-all
rm -rf $TMPDIR/react-native-packager-cache-*
rm -rf $TMPDIR/metro-bundler-cache-*
rm -rf node_modules/
npm cache clean
npm cache verify
npm start -- --reset-cache

Still the same error

@donjo9
Copy link

donjo9 commented Aug 26, 2018

do you have a repo that produces that error that we could test on?

@tamirrab
Copy link

tamirrab commented Aug 26, 2018

How can I do it?

I get this Error on the Terminal:

::1 - - [26/Aug/2018:10:15:47 +0000] "GET /index.bundle?platform=ios&dev=true&minify=false HTTP/1.1" 200 - "-" "appName/0.2.8 CFNetwork/901.1 Darwin/18.0.0"

@danielgindi
Copy link
Contributor

There's one more thing I did before it started working properly, which might not be related to rc.3:
react-native start --projectRoot path/to/project/folder --resetCache
And I used the camelCase arguments specifically.
So it could by either the camel case resetCache, which is even more suspicious because if I recall correctly there has been a commit recently about passing on the resetCache argument,
Or it could be the explicit projectRoot. But now I run it normally.

@joejordan
Copy link

Same issue here on 0.57.0-rc.3 Windows 10. Like @dmead, I am also attempting to get away from the AccessibilityInfo bug in 0.56 Windows that prevents any apps from working. Attempted solutions proposed by @danielgindi without success, still the exact same error.

@donjo9
Copy link

donjo9 commented Aug 27, 2018

@joejordan i will ask you the same question ;) do you have a repository that produces this error, that we could clone and test on :)

@164738777

This comment has been minimized.

@donjo9
Copy link

donjo9 commented Aug 27, 2018

@164738777 same question ;) do you have a repository that produces this error, that we could clone and test on :)

@joejordan
Copy link

joejordan commented Aug 27, 2018

@donjo9 here's one. https://github.com/joejordan/0.57rc3-WindowsCrash

Was able to duplicate the issue on two Windows 10 systems.

Edit: Here's a zip of the full repo including all node modules: https://drive.google.com/open?id=1QeysYZm5-mddwwYSUiwdMt5_M66ojlUq

@gengjiawen
Copy link
Contributor

gengjiawen commented Aug 28, 2018

@joejordan Your .babelrc is wrong. If you have other questions, please try create a new project and make some diff in case you miss something.
It should be:

{
  "presets": ["module:metro-react-native-babel-preset"]
}

@joejordan
Copy link

@gengjiawen that must have been generated by create-react-native-app because I don't think I touched that file. Regardless, I tried it with that preset and the 'undefined' red screen of death still appears upon launch.

@gengjiawen
Copy link
Contributor

Can you try to initial a new project using rc3 ?

@chakrihacker
Copy link
Contributor

@gengjiawen this issue exists in my windows 10 too, can you point on what files to look for, maybe I can give a try. Thanks

@gengjiawen
Copy link
Contributor

check my previous comment, I have not tested it, maybe need more file to change.

@donjo9
Copy link

donjo9 commented Aug 28, 2018

I found the following so far:

@joejordan s repo failed on my machine as well, changing the .babelrc and changing the

-"babel-preset-react-native": "5.0.2",
+"metro-react-native-babel-preset": "0.43.5",

in package.json did nothing.
deleting node_modules before doing "yarn" or "npm install" had no effect.

What did work, was initial a new project with rc3 with react-native init albums --version 0.57.0-rc.3 installing that app on my phone with react-native run-android, kill the bundler from the new project, and then running the bundler from the "faulty" project with yarn start or npm run start

@kelset
Copy link
Contributor

kelset commented Aug 28, 2018

By looking at the comments, I suggest you folks wait until the changelog for 0.57 is out, we'll try to have a list of manual steps you have to do to correctly upgrade your projects to 0.57 since a few things are changing.

Again, we are still on RC stage so don't rush into it.

@donjo9
Copy link

donjo9 commented Aug 28, 2018

Might as well be the same :D
After my latest post i did a
react-native start --reset-cache
And now i cant seem to recreate the issue, not even with a fresh clone of @joejordan s repo

edit: ok now its back, even in my "working" App, but again a react-native start --reset-cache fixed it

@donjo9
Copy link

donjo9 commented Aug 28, 2018

Sorry for keep spamming, but this got me from a clean git clone to a working app
git clone https://github.com/joejordan/0.57rc3-WindowsCrash Test057rc3
cd Test057rc3
npm install
react-native upgrade answering y to every question
Install

platforms;android-27 Android SDK Platform 27
build-tools;27.0.3 Android SDK Build-Tools 27.0.3

with the Android SDK manager
react-native run-android this will still fail
kill bundler
react-native start --reset-cache

From this point on react-native run-android should work

@kelset kelset added the Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used. label Aug 28, 2018
@joe307bad
Copy link

I can also confirm some of @donjo9's process. Here is what got me from a clean git repo to a working app:

  1. Update Android SDK Build-Tools via Android SDK Manager
  2. react-native init MyApp2 --template typescript --version 0.57.0-rc.3
  3. cd MyApp2
  4. react-native upgrade
  5. Answer "y" to all questions
  6. Point genymotion Android SDK to folder location for my Windows user (genymotion > Setting > ADB)
  7. Restart computer
  8. Open genymotion emulator (Samsung GS8 API 26)
  9. react-native run-android

At this point the bundler booted up, the app installed on the emulator, and I was able to debug via chrome dev tools. I will update this later tonight when I can test on a different computer.

@kidmysoul
Copy link

I solved this error by comparing my project to the new 0.57.0 version project and changed some files and reboot my PC

@brunolemos
Copy link
Contributor

brunolemos commented Sep 4, 2018

I'm having this issue on any project with 0.57 rc3, starting from scratch or upgrading.
I'm using macOS Mojave beta.

@pontusab
Copy link

pontusab commented Sep 7, 2018

I can confirm that this works with the latest 0.57 rc4:

package.json

    "@babel/cli": "^7.0.0",
    "@babel/core": "^7.0.0",
    "metro-react-native-babel-preset": "^0.45.1",

.babelrc

"presets": ["module:metro-react-native-babel-preset"]

@haggholm
Copy link

haggholm commented Sep 7, 2018

@pontusab When you say that “this works”, do you mean that you can reproduce the issue or that it’s gone away? I am still seeing this error with 0.57.0-rc.4.

@pontusab
Copy link

pontusab commented Sep 7, 2018

@haggholm had this issue undefined is not a function(evaluating '_this.registerEvents()') on 0.57.0-rc.2 but now with the configuration in .babelrc and 0.57.0-rc.4 it works.

@yanivnizry
Copy link

after cache reset (react-native start --reset-cache) it worked for me also

@gengjiawen
Copy link
Contributor

Looks resolved.

@164738777
Copy link

164738777 commented Sep 10, 2018

I'm still has this issue in 0.57.0-rc.4

There is my package.json

{
  ...
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "run-ios": "node node_modules/react-native/local-cli/cli.js run-ios --simulator=\"iPhone 7\"",
    "test": "jest"
  },
  "dependencies": {
    "core-decorators": "^0.20.0",
    "fbemitter": "^2.1.1",
    "glamorous-native": "^1.4.0",
    "humps": "^2.0.1",
    "jshashes": "^1.0.7",
    "lodash": "^4.17.4",
    "moment": "^2.20.1",
    "prop-types": "^15.6.0",
    "react": "^16.4.1",
    "react-native": "^0.57.0-rc.4",
    ...
  },
  "devDependencies": {
    "@babel/plugin-proposal-decorators": "^7.0.0",
    "babel-eslint": "^8.0.3",
    "babel-jest": "22.0.1",
    "babel-plugin-module-resolver": "^3.1.1",
    "babel-preset-react-native": "^5.0.2",
    "eslint": "^4.13.1",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-import-resolver-babel-module": "^5.0.0-beta.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-jsx-grouped-sort-props": "file:eslint-plugins\\jsx-grouped-sort-props",
    "eslint-plugin-react": "^7.5.1",
    "jest": "22.0.1",
    "react-test-renderer": "16.0.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

And the .babelrc

{
 ...
  "presets": ["react-native"],
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ]
}

@donjo9
Copy link

donjo9 commented Sep 11, 2018

@164738777 have you tried this

if so, do you have a repo that reproduces this error that we could try it with ?

@apcjs
Copy link

apcjs commented Sep 11, 2018

Tried rc4 on my Windows 10 machine. Worked fine. Just the following 2 commands.

react-native init MyApp2 --version 0.57.0-rc.4
react-native run-android

Took a while to download a number of packages and finally run on my emulator. Reload works extremely fast compared to 0.55. Waiting for the final .057 release!

@facebook facebook locked as resolved and limited conversation to collaborators Sep 11, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Platform: Windows Building on Windows. Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.
Projects
None yet
Development

No branches or pull requests