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
npm -v
– Malayalam