Response-native: the `run-android` command is not recognized. May be caused by npm installation

Recently, I started getting this problem when I install the package responsible for the reaction (for example:) react-navigationin my project, a whole bunch of packages are removed (including reacting, reacting - I think).

And then, when I try to run the " run-android" command , it says that it does not recognize.

I recently updated to the latest npmand react-native-cli. Is this 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

Following are the steps to recreate:

  • Step 1 - Create a project. enter image description here

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

  • Step 3 - Install “respond to native-navigation” to the project. enter image description here

Notice in the image above. Seems like all the other packages are removed from the project.<br/><br/>
  • 4 - "run-android". (, ) enter image description here

, - ?

+4
2

.

npm install , package-lock.json npm install .

react-navigation , .

+3

.

  • react-native init NavTest (Cli )
  • -lock.json
  • npm install --save react-navigation
  • -lock.json
  • npm install
  • react-native run android , , , . https://reactnavigation.org/ .

index.android.js

import React, { Component } from 'react';
import { 
  AppRegistry,
  Button,
} from 'react-native';
import {
  StackNavigator,
} from 'react-navigation';



class HomeScreen extends Component {
  static navigationOptions = {
    title: 'Welcome',
  };
  render() {
    const { navigate } = this.props.navigation;
    return (
      <Button
        title="Go to Jane profile"
        onPress={() =>
          navigate('Profile', { name: 'Jane' })
        }
      />
    );
  }
}

class ProfileScreen extends Component{
  static navigationOptions = {
    title: 'Jane',
  };
  render() {
    return (null);
  }
}

const NavTest= StackNavigator({
  Home: { screen: HomeScreen },
  Profile: { screen: ProfileScreen },
});

AppRegistry.registerComponent('NavTest', () => NavTest);
-1

All Articles