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 an object (evaluating 'ReactInternals.ReactCurrentOwner') #13874

Closed
Benjamin-Dobell opened this issue May 9, 2017 · 24 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@Benjamin-Dobell
Copy link
Contributor

Benjamin-Dobell commented May 9, 2017

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
@Benjamin-Dobell
Copy link
Contributor Author

Benjamin-Dobell commented May 9, 2017

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
Copy link
Contributor Author

Benjamin-Dobell commented May 9, 2017

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
Copy link
Contributor Author

Benjamin-Dobell commented May 9, 2017

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
Copy link

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

@Benjamin-Dobell
Copy link
Contributor Author

@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
Copy link

i got the same problem after upgrading to 0.45

@rclai
Copy link
Contributor

rclai commented Jun 10, 2017

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

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

@Liqiankun
Copy link

@Benjamin-Dobell Thank you !

@joimxjtuse
Copy link

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
Copy link

shenxiaolin commented Jul 6, 2017

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
Copy link
Contributor

@Benjamin-Dobell It worked. Thanks.

@simonbengtsson
Copy link

simonbengtsson commented Jul 29, 2017

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
Copy link

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
Copy link

tiofabby commented Aug 8, 2017

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
Copy link

Thanks! Resolved it!

@av1v3k
Copy link

av1v3k commented Aug 9, 2017

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
Copy link

av1v3k commented Aug 19, 2017

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
Copy link

@tiofabby it works for me ,i used

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

@iegik
Copy link

iegik commented Aug 31, 2017

@LinkRober #15621

@yudiandian
Copy link

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

@koliatest
Copy link

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

@dienast
Copy link

dienast commented Dec 18, 2017

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

@tetogomez
Copy link

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

@tintorres
Copy link

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

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests