I have two different ReactNative-Projects:
What caused this for me was running npm install --save axios
when actually the system was previously using yarn
instead of npm
.
To solve this, instead of deleting the node_modules
folder, which can lead to more problems, and if you prefer to run npm
anyway or don't have a preference either way, the error should have instructed for you to run npm install
. If you literally follow those instructions, you will be able to run: react-native run-ios
afterwards.
For me, the only thing that worked was to checkout again my repository from zero and run:
npm install -g react-native-cli yarn
yarn
git submodule update --init --recursive
In my case, it was an issue with the package.json file. I deleted a section during a test. I recover a previous file with the deleted section and everything was working again.
I created a brand new react-native project using
$ react-native init projectName
and ran from root of the project
$ react-native run-ios
Everything worked fine and iOS simulator fired up as expected.
Than I installed prop-types
node module using npm install prop-types --save
. Re-ran $ react-native run-ios
and ran into this error Command run-ios unrecognized
Solution:
From the root of my project, removed node_module
and re-installed modules using npm. Commands below
$ rm -rf node_modules/
$ npm install
$ react-native run-ios
Delete the node-modules. Its because the packages are not installed.
rm -rf node_modules
npm install
then run your project
react-native run-ios
this works for me
sudo npm install -g react-native-cli --force
then
react-native run-ios