Skip to main content

React Native v0.44 - Unable to resolve module react/lib/ReactComponentTreeHook

I have this app built with React Native v0.44. The current version is 0.48 but I haven't had time to upgrade during the summer, and when I tried to do so I got all kinds of weird dependency errors so I decided to stick with 0.44 for a little while longer.

Yesterday I bought myself a new Macbook to finally put my old choking Macbook Air from 2012 out of its misery. I cloned my git repo, ran npm install, but when I tried to launch the app in the iOS simulator it stopped with the following error:

Unable to resolve module ReactComponentTreeHook from node_modules/react-native/Libraries/Performance/Systrace.js

I tried to clean up and reinstall a couple of times since that usually solves quite of lot of dependency errors, but this error persisted and I had no clue what was causing it. After searching the Internet for a little while I found this page presenting a couple of possible solutions worth trying.

The first solution suggests using react-native-git-upgrade, and that's the one I started with. Once again, I made sure to clean up everything by running the commands suggested by the simulator stack trace, and then install and upgrade. Note that the exact version number of React Native is specified as an argument to react-native-git-upgrade. Like this:

> watchman watch-del-all
> rm -rf node_modules
> rm -rf $TMPDIR/react-*
> react-native-git-upgrade 0.44.0

Finally, I ran react-native run-ios again, and that's it! The app started up just fine without any errors.

The second solution, that I didn't need to try, handled the case when the React dependency is incorrect or missing. I know I've seen this warning before a lot of times, but it has never seemed to stop my app from running.

Basically, if you get the following warning:

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

Then try to install the correct React dependency manually:

> npm install -save react@16.0.0-alpha.6

Which React version to use of course depends on the version of React Native. A table of matching versions can be found here: