Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native: Command `run-android` unrecognized. Maybe caused by npm install

Recently I started getting this issue, when I install a react-native package (eg: react-navigation) into my project, a whole bunch of packages are been removed (including react, react-native i think).

And then when i try to run command "run-android", it says it doesn't recognize.

I recently updated to the latest npm and react-native-cli. Is it something wrong with "npm install"? or react-native?

node version: 8.1.2 <br/>
react-native-cli: 2.0.1 <br/>
react-native: 0.45.1 <br/>
react-navigation: 1.0.0-beta.11

Below are the steps to re-create:

  • Step 1 - Create project. enter image description here

  • Step 2 - Run the "run-android" command (This works). enter image description here

  • Step 3 - Install "react-native-navigation" into project. enter image description here

Notice in the image above. Seems like all the other packages are removed from the project.<br/><br/>
  • Step 4 - Try running "run-android" command again. (will fail, but used to work before) enter image description here

Any idea on what the issue is and any way to solve it?

like image 317
Yeshan Jay Avatar asked Jun 19 '17 11:06

Yeshan Jay


People also ask

What does NPX React Native run Android Command do?

Step 2: Start your application If everything is set up correctly, you should see your new app running in your Android emulator shortly. npx react-native run-android is one way to run your app - you can also run it directly from within Android Studio.

How do I install React Native in Windows 10?

Get started with React Native by installing required toolsInstall Visual Studio Code (or your code editor of choice). Install Android Studio for Windows. Android Studio installs the latest Android SDK by default. React Native requires Android 6.0 (Marshmallow) SDK or higher.

How do I run a React Native app?

Running your React Native application Install the Expo client app on your iOS or Android phone and connect to the same wireless network as your computer. On Android, use the Expo app to scan the QR code from your terminal to open your project. On iOS, follow on-screen instructions to get a link.


1 Answers

Found the solution here.

At first running npm install didn't work, but then, deleting the package-lock.json file and running npm install did the job.

After that I installed react-navigation package seperately and it worked fine.

like image 132
Yeshan Jay Avatar answered Nov 10 '22 01:11

Yeshan Jay