0

I am trying to open an app via Android Studio. I have previously used Expo as my React Native development environment, but this app uses the React Native CLI. I have followed all of the instructions for the CLI setup here: https://reactnative.dev/docs/environment-setup

However, when I finally try to run "npx react-native run-android", something strange happens. The terminal starts chewing metadata and stuff as if it received my command, but then after a while it finishes with the text:

error Unrecognized command "run-android".
info Run "react-native --help" to see a list of all available commands.

A few observations:

  • Running "react-native --help" also returns an error, because it "is not recognized as the name of a cmdlet, function, script file, or operable program."
  • After the chewing of metadata but before the error, there are many lines of codes with warnings, which all look like this (regarding a variety of libraries):

warn Package @react-native-community/eslint-config has been ignored because it contains invalid configuration. Reason: Cannot find module '@react-native-community\eslint-config\package.json'

  • The developer said I did not need to install any particular libraries or modules - perhaps he was wrong? Still doesn't solve the issue though.
  • I have tried writing the same commands in different terminals, but the result is the same.
  • I have tried using the terminal debugger in Visual Studio code as suggested in the thread below, but that did not make me any wiser. Getting error - Unrecognized command "run-android", when running react native,
Zuzim
  • 75
  • 4
  • 12
  • maybe try "npx react-native run-android" <-- with a space instead of a - – Nick Howard Aug 20 '20 at 14:31
  • It does not recognize either the command "react" or the command "run". – Zuzim Aug 21 '20 at 06:28
  • I have edited my post now, at first it said that I used the command "npx-react-native run-android", but what I meant was "npx react-native run-android", without a dash between react and native. THAT is when it returns: Unrecognized command "run-android". Sorry for the confusion. – Zuzim Sep 03 '20 at 07:26

4 Answers4

0

Run npm install first. That will install the missing modules it is complaining about. Then run npx react-native run-android

andreofthecape
  • 1,166
  • 11
  • 24
0

Try npm install or hover over the "android" command in package.json file and then click on Run Script it worked for me.

0

I also got the same problem recently. In my case I had not installed dependencies. Running npm install worked in my case

0

right now iam also facing same problem , above or below comments i tried some many times but not single cmd workes me , my errors is:

" >npx react-native run-andriod error: unknown command 'run-andriod' (Did you mean run-android?)" "'run-andriod' is not recognized as an internal or external command, operable program or batch file.":(