I have been working with react-native
project in another pc and it has been working correctly. Now I cloned project to another device where I have react-native
installed since I work with other project and I cannot run it.
When I run react-native run-android
I get this error:
Cannot run program "npx": error=2, No such file or directory
I'm using Android Studio 4 on Mac OS Catalina 10.15.6. I solved the problem by running Android Studio with bellow command on console.
$ open -a "Android Studio.app"
Simple steps you need to go through to make it work with npx
sudo npm uninstall -g react-native-cli
sudo npm i -g npx
npx react-native run-android
More detailed explanation why this is happenig
Issue was that Facebook is not using anymore react-native-cli
as they are using npx
.
As stated in Facebook page:
If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues.
So i had to run sudo npm uninstall -g react-native-cli
to remove react-native-cli
They also say that npx
is shipped with nodejs
but that wasn't my case.
React Native has a built-in command line interface, which you can use to generate a new project. You can access it without installing anything globally using npx, which ships with Node.js.
So I had to install it using sudo npm i -g npx
After installing npx
then just need to run npx react-native run-android
.
Be aware of npx
before react-native run-android
Now you don't have any command react-native
now we only have 'npx' and react-native run-android
is just a parameter for npx
. For ex. to start metro we should run npx react-native start
I had the same issues, so I followed these steps:
olderAndroidStudio
, on mac).don't
click on import settings from Existing.I additionally uninstalled react-native-cli using the method given in the accepted answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With