1

I'm attempting to upgrade React Native and I'm running into the following:

error: bundling: UnableToResolveError: Unable to resolve module `react/lib/ReactComponentTreeHook` from `/Users/anthony/dev/apptova-react/node_modules/react-native/Libraries/Performance/Systrace.js`: Module does not exist in the module map or in these directories:
  /Users/anthony/dev/apptova-react/node_modules/react-native/node_modules/react/lib
,   /Users/anthony/dev/apptova-react/node_modules/react/lib

I'm so confused. I can't find any library named ReactComponentTreeHook in node_modules, anywhere.

I've tried removing the node_modules folder and reinstalling, nada. I've also cleared watchman watches and reset the packager cache.

EDIT: I kept running into issues that seemed to stem from react-native-maps so I so I reset back to a working stable version, uninstalled react-native-maps, and ran react-native-git-upgrade (again).

Now I'm getting:

error: bundling: UnableToResolveError: Unable to resolve module `react/lib/ReactDebugCurrentFrame` from `/Users/anthony/dev/apptova-react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js`: Module does not exist in the module map or in these directories:
  /Users/anthony/dev/apptova-react/node_modules/react-native/node_modules/react/lib
,   /Users/anthony/dev/apptova-react/node_modules/react/lib

I'm just trying to latest, my package.json dependencies are simple so I don't think its conflicts with a third-party code base:

"dependencies": {
    "react": "15.4.1",
    "react-native": "^0.43.1",
    "react-native-drawer": "^2.3.0"
  },
  "devDependencies": {
    "babel-jest": "18.0.0",
    "babel-plugin-transform-flow-strip-types": "^6.21.0",
    "babel-preset-react-native": "1.9.1",
    "deepmerge": "^1.3.2",
    "flow-bin": "^0.37.4",
    "jest": "18.0.0",
    "react-test-renderer": "15.4.1"
  },

Again, went throught the process of clearing watchman watches, node modules, reseting package manager and still get this error.

EDIT 2: After spending two solid days of trying to get this working I created a new blank project and migrated my code over.

callmetwan
  • 1,205
  • 2
  • 14
  • 31

3 Answers3

2

Make sure version in your package.json file is the version you want.

For example, "react-native: ^0.43.3" is not same as "react-native: 0.43.3".

Clean up and re-install everything.

If the error still there, then try to install react-native-git-upgrade

$ npm install -g react-native-git-upgrade

and then run

$ react-native-git-upgrade x.y.z(version you want to upgrade to)

for me it works.

If your version is too old, then you should follow the old version document to upgrade.

Tyreal Gray
  • 373
  • 1
  • 7
2

This could also happen if you don't have the correct version of react required by the version of react-native. If this is the case, you would get a warning like this when you run npm install.

npm WARN react-native@0.43.4 requires a peer of react@16.0.0-alpha.6 but none was installed.

To fix this problem, stop the react packager and upgrade the version of react by running the following command

npm install -save react@16.0.0-alpha.6

Now, re-run the app and hopefully the issue would go away.

I think recently many of the modules under react/lib were moved to react-dom/lib, which is why the packager can't find some modules

Vijay
  • 1,082
  • 8
  • 6
  • daaaamn!!! it worked... but how!? i already got `"react": "^16.0.0-alpha.6",` on my package.json, remove all node_modules, npm install, react-native-git-upgrade, eeeverything, and it was throwing the same error over and over, i was so annoyed!!! why is this bug even happening? is like npm isn't recognizing the package from the json and not installing it... this is super weird. Thanks! i don't know why this answer wasn't chosen as the solver. – msqar May 15 '17 at 22:32
  • 1
    I'm not positive about this explanation but when you specify "^", , It will update you to the most recent major version (the first number). ie ^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0. – Vijay May 22 '17 at 21:25
  • ohhh, because alpha.6 is not a "stable" last version and therefore, it would update to the latest stable version? is that what you mean? makes sense, tho. – msqar May 22 '17 at 22:10
  • 1
    I think the dependency resolution is a bit broken as explained in [this answer](https://stackoverflow.com/a/20765400/5796780). In such cases, I would provide the exact version to use (version numbers without ^,~ etc.,) rather than let npm resolve it for me. – Vijay May 22 '17 at 23:15
0

I followed following steps and it's working

• Deleted node_modules folder

• Replaced ^16.0.0-alpha.6 with "react": "16.0.0-alpha.3"

• npm install

• react-native run-android

Rajesh N
  • 6,198
  • 2
  • 47
  • 58