I have two different ReactNative-Projects:
This may sound silly, but make sure you cd to your project directory. If that fails then perform the npm install in the other answers.
This happens when the project has an older version of react native. You can update the react version or for people who do not want to upgrade, just open the .xcodeproj file in iOS dir and hit the play button in the Xcode.
What caused this for me was running npm install --save [package]
when actually the system has previously been using yarn
instead of npm
.
To solve this I just deleted the node_modules
folder and ran: yarn install
and after that react-native run-ios
(or android) works fine.
I also fell in this error and the reason was
I was using yarn link
command in wrong folder
Just update the version of react native in your project with the following command:
$> npm install --save react-native@latest
I found a solution that works for me. Update the version of react native in your project:
npm install --save react-native@latest
then upgrade your npm version
npm i npm@latest -g
then move directory folder 1 level up, type
cd ..
make a new react-native installation folder
react-native init NewProject
then go to your project folder(NewProject), after that
react-native run-ios
should work fine.