Skip to content

undefined is not an object (evaluating 'ReactInternals.ReactCurrentOwner') #13874

Closed
@Benjamin-Dobell

Description

@Benjamin-Dobell

Description

The last couple of days I've been attempting to debug the current React Native master (updated the HEAD a few times) on either iOS or Android, however app execution fails immediately after receiving the bundle with the exception:

undefined is not an object (evaluating 'ReactInternals.ReactCurrentOwner')

I've attempted clean app rebuilds many times:

watchman watch-del-all
rm -rf ./node_modules
yarn cache clean
rm -rf $TMPDIR/react-*
yarn install
npm start -- --reset-cache

Also, cleaned the Android builds (./gradlew clean) and iOS builds ("Clean" and "Clean Build Folder") and rebuilt.

Reproduction Steps and Sample Code

  1. Check out RN master.

  2. Build the Android libs using:

./gradlew installArchives
  1. Check in the resultant android/ directory (force add as it's .gitignore'd) and push to a Github branch.

  2. In a RN app swap from the NPM published package to the published branch e.g.

yarn remove react-native
yarn add github:benjamin-dobell/react-native#builds/dynamic-toolbar
  1. Rebuild the app cd android; ./gradlew clean; ./gradlew installDebug, or for iOS from XCode.

  2. Launch the RN packager:

yarn start

Note: If you haven't grabbed flowtype from master this will fail here. I just temporarily replaced the spread operator usage in type definitions with copy and paste contents.

  1. Launch the app on an Android or iOS device. Wait for the packager to bundle the package.

Error then occurs.

It's perhaps worth noting that, I believe, this is the exact procedure I've followed in the past to build and test (and eventually contribute back) my RN forks.

Solution

Unsure.

Additional Information

  • React Native version: 73fc439
  • Platform: Android & iOS
  • Development Operating System: macOS 10.12.4 (16E195)
  • Dev tools:
    • android-ndk-r10e
    • Xcode 8.3.2 (Build version 8E2002)
    • node v7.9.0
    • yarn 0.23.4
    • npm 4.2.0

Activity

Benjamin-Dobell

Benjamin-Dobell commented on May 9, 2017

@Benjamin-Dobell
ContributorAuthor

It doesn't seem obviously related to me, but perhaps a hint toward the underlying cause. When you run the packager with:

yarn start -- --reset-cache

instead of simply yarn start.

You end up with a few warnings about duplicate modules:

React packager ready.

Loading dependency graph...jest-haste-map: @providesModule naming collision:
  Duplicate module name: babylon
  Paths: <PROJECT PATH>/node_modules/react-native/node_modules/babylon/package.json collides with <PROJECT PATH>/node_modules/react-native/node_modules/babel-traverse/node_modules/babylon/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.
jest-haste-map: @providesModule naming collision:
  Duplicate module name: core-js
  Paths: <PROJECT PATH>/node_modules/react-native/node_modules/core-js/package.json collides with <PROJECT PATH>/node_modules/react-native/node_modules/fbjs/node_modules/core-js/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.
Loading dependency graph, done.
Benjamin-Dobell

Benjamin-Dobell commented on May 9, 2017

@Benjamin-Dobell
ContributorAuthor

Full trace (from iOS):

undefined is not an object (evaluating 'ReactInternals.ReactCurrentOwner')

<unknown>
   ReactGlobalSharedState.js:18:36
loadModuleImplementation
   require.js:174:12
<unknown>
   ReactDebugTool.js:18:39
loadModuleImplementation
   require.js:174:12
<unknown>
   ReactInstrumentation.js:19:31
loadModuleImplementation
   require.js:174:12
<unknown>
   ReactNativeMount.js:15:35
loadModuleImplementation
   require.js:174:12
<unknown>
   ReactNativeStack.js:16:31
loadModuleImplementation
   require.js:174:12
<unknown>
   ReactNative.js:18:12
loadModuleImplementation
   require.js:174:12
<unknown>
   NativeMethodsMixin.js:14:26
loadModuleImplementation
   require.js:174:12
<unknown>
   View.js:14:35
loadModuleImplementation
   require.js:174:12
<unknown>
   MapMarker.js:25:5
loadModuleImplementation
   require.js:174:12
<unknown>
   MapView.js:12
loadModuleImplementation
   require.js:174:12
<unknown>
   index.js:1
loadModuleImplementation
   require.js:174:12
<unknown>
   <APP FILE>:13
loadModuleImplementation
   require.js:174:12
<unknown>
   <APP FILE>:19
loadModuleImplementation
   require.js:174:12
<unknown>
   routes.js:1
loadModuleImplementation
   require.js:174:12
<unknown>
   Navigator.js:12
loadModuleImplementation
   require.js:174:12
<unknown>
   <APP FILE>:49
loadModuleImplementation
   require.js:174:12
<unknown>
   setup.js:22
loadModuleImplementation
   require.js:174:12
<unknown>
   index.ios.js:4:22
loadModuleImplementation
   require.js:174:12
guardedLoadModule
   require.js:119:45
global code
   <unknown file>:0
Benjamin-Dobell

Benjamin-Dobell commented on May 9, 2017

@Benjamin-Dobell
ContributorAuthor

I could have sworn I updated my React peer dependency. Apparently not!

That was the cause. Sorry!

A note to anyone else trying to run RN from master. Double check the react version in RN's package.json matches the one in your app's yarn lockfile.

winterrain5

winterrain5 commented on Jun 9, 2017

@winterrain5

i have the same problem in the ios,is there anybody solved it?

Benjamin-Dobell

Benjamin-Dobell commented on Jun 9, 2017

@Benjamin-Dobell
ContributorAuthor

@winterrain5 As I mentioned, make sure you've installed the correct version of React. If you're using React Native 0.45:

yarn add react@16.0.0-alpha.12
deathnopool

deathnopool commented on Jun 9, 2017

@deathnopool

i got the same problem after upgrading to 0.45

rclai

rclai commented on Jun 10, 2017

@rclai
Contributor

I'm assuming that you also need to update this too if you have it?

"react-test-renderer": "16.0.0-alpha.12"
Liqiankun

Liqiankun commented on Jun 12, 2017

@Liqiankun

@Benjamin-Dobell Thank you !

joimxjtuse

joimxjtuse commented on Jun 22, 2017

@joimxjtuse

i have the same question in my android project. how to fix it ? i, package.json:
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.45.1"
}

shenxiaolin

shenxiaolin commented on Jul 6, 2017

@shenxiaolin

Hi
Same problem like above
My package.json

"name": "RNDemo",
"version": "1.0.0",
"description": "",
"main": "index.android.js",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.6.1",
"react-native": "^0.46.0"
}

How to fixed it ??

rajsuvariya

rajsuvariya commented on Jul 10, 2017

@rajsuvariya
Contributor

@Benjamin-Dobell It worked. Thanks.

simonbengtsson

simonbengtsson commented on Jul 29, 2017

@simonbengtsson

Hmm. I'm getting the same message with react-native: 0.46.0 and react: 16.0.0-alpha.12. Probably me doing something stupid on my machine though as I get the same issue no matter what react native example I'm running.

EDIT: My issue was that I did not move the ios project to an ios sub folder.

sayanibhattacharjee

sayanibhattacharjee commented on Aug 4, 2017

@sayanibhattacharjee

This is my package.json. Is there any workaround?
{ "name": "NowPurchase", "version": "0.1.0", "private": true, "devDependencies": { "react-native-scripts": "0.0.50", "jest-expo": "~18.0.0", "react-test-renderer": "16.0.0-alpha.12" }, "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js", "scripts": { "start": "react-native-scripts start", "eject": "react-native-scripts eject", "android": "react-native-scripts android", "ios": "react-native-scripts ios", "test": "node node_modules/jest/bin/jest.js --watch" }, "jest": { "preset": "jest-expo" }, "dependencies": { "expo": "^18.0.3", "react": "16.0.0-alpha.12", "react-native": "^0.45.1", "react-native-collapsing-toolbar": "^1.0.0-beta.4", "react-native-drawer-menu": "^0.2.4", "react-native-keyboard-aware-scroll-view": "^0.2.9", "react-native-material-design": "^0.3.7", "react-native-util": "^1.0.2", "react-native-vector-icons": "^4.3.0", "react-navigation": "^1.0.0-beta.11", "util": "*" } }

tiofabby

tiofabby commented on Aug 8, 2017

@tiofabby

Hello
I had same issue when migrating from recat native 0.42.1 to 0.47.0
I did the following and it fixed almost all my issues :

  • delete/remove yourProject/node-modules folder
  • set up package.json with "react": "16.0.0-alpha.12" and "react-native": "0.47.0"
  • npm install
  • cd android && gradlew clean
  • cd.. && npm start -- --reset-cache
    (some react native libraries I had had to be updated also to last version supporting 0.47)
sayanibhattacharjee

sayanibhattacharjee commented on Aug 8, 2017

@sayanibhattacharjee

Thanks! Resolved it!

av1v3k

av1v3k commented on Aug 9, 2017

@av1v3k

followed @tiofabby @saayani But, NOT WORKING.

image

package.json configuration is as below.

{
	"name": "AwesomeProject",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"start": "node node_modules/react-native/local-cli/cli.js start",
		"test": "jest"
	},
	"dependencies": {
		"react": "16.0.0-alpha.12",
		"react-native": "0.47.0"
	},
	"devDependencies": {
		"babel-jest": "20.0.0",
		"babel-preset-react-native": "1.9.1",
		"jest": "20.0.0",
		"react-test-renderer": "16.0.0-alpha.6"
	},
	"jest": {
		"preset": "react-native"
	}
}
av1v3k

av1v3k commented on Aug 19, 2017

@av1v3k

OK. I got it resolved by doing the things below.

  1. Check in NPM repo all dependencies are latest for the Project Development.
  2. Update each dependencies and run react native again.

Problem Solved ! @tiofabby @saayani 👍

LinkRober

LinkRober commented on Aug 23, 2017

@LinkRober

@tiofabby it works for me ,i used

"dependencies": {
    "react": "16.0.0-alpha.12",
    "react-native": "^0.47.2"
  }
iegik

iegik commented on Aug 31, 2017

@iegik
yudiandian

yudiandian commented on Oct 13, 2017

@yudiandian

解决方法:把react,react-native安装如下版本就好了
"react": "^16.0.0-alpha.12",
"react-native": "^0.46.4",

koliatest

koliatest commented on Oct 30, 2017

@koliatest

解决方法:把react,react-native安装如下版本就好了
What...?

dienast

dienast commented on Dec 18, 2017

@dienast

I removed the '^' in front of "16.0.0-alpha.12" and it worked.

tetogomez

tetogomez commented on Feb 6, 2018

@tetogomez

Yep I added react@16.0.0-alpha.12 and it worked for me.
you guys saved my life hahaha thks !!

tintorres

tintorres commented on Mar 20, 2018

@tintorres

react@16.0.0-alpha.12 worked for me too. thanks

locked as resolved and limited conversation to collaborators on May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @iegik@Benjamin-Dobell@rclai@av1v3k@simonbengtsson

        Issue actions

          undefined is not an object (evaluating 'ReactInternals.ReactCurrentOwner') · Issue #13874 · facebook/react-native