react-native: Unable to resolve module react-native
We use GitHub Issues for bugs.
Description
I recently created a new project using react-native init MyProject
. The app ran fine initially.
However now, when I run react-native run-ios
or try to use xcode to run the app. I get the following error screen.
I have followed the suggested instructions and have ran the following
rm -rf node_modules
rm -rf $TMPDIR/react-* --reset-cache
rm -rf node_modules/react-native/packager/packager.sh --reset-cache
npm cache clean
npm i
But I still experience the same problem
I have verified that react-native
is in fact installed at the correct location.
- React Native version: 0.38.0
- Platform: iOS
- Operating System: MacOS
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 10
- Comments: 26 (1 by maintainers)
+1 - i’ve gutted 2 projects now because of this, yikes
I resolved this using the
react-native-git-upgrade
package instead ofreact-native upgrade
to upgrade the project. And because of this I had to useyarn
instead ofnpm
.So, i did something like that:
Actually found something. I was getting the same error and just now after my first comment I checked if I had yarn installed and which version. After hitting
yarn -v
it installed itself and all of the dependancies that were removed during mynpm install --save firebase
. After the install, in another terminal instance I re-rannpm run start
which didn’t have any issues then in the main terminal instance I ranreact-native run-ios
and that totally ran smoothly. When the problem (which this thread is about) was happening I couldn’t runreact-native run-ios
because it didn’t even recognize the root folder as a react-native file. Now it does. So give it a try. It doesn’t seem like a quick fix, it seems stable now. Saying that we’ll see how it goes… keeping a watchful eye.+1
Using RN v44.2 and this is happening to me, the workaround isn’t working either.
After upgrading to react native 0.45.1 i have same issue. What i did:
npm install --save react-native@0.45.1
react-native upgrade
react-native link
Result - Unable to find module React Native
I just ran into this in a brand new project. Definitely not stale and none of the suggested actions change anything.
I resolved this with this comment after trying every solution under the sun.
ios/
orandroid/
react-native eject
<-- this was what did it for mereact-native-git-upgrade
react-native link
react-native run-ios