0

I am new to react when I import stacknavigator from react-navigation or listitem from native-base .

  1. Created new project on expo.
  2. npm install --save react-navigation .
  3. npm install .
  4. npm startenter code here

I continuously get this error, tried the solution from GitHub repo issue number 4968 but that's not helpful, can you help, please? unable to resolve react-navigation, module doesn't exist in module map

App.js

 
{import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {StackNavigator} from 'react-navigation'
import LoginScreen from './Screens/LoginScreen'
import HomeScreen from './Screens/HomeScreen'
export default class App extends React.Component {
  render() {
    return (
      <AppNavigator/>
    );
  }
}
const AppNavigator = StackNavigator({
  LoginScreen : {screen : LoginScreen},
  HomeScreen : {screen : HomeScreen}
})
const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});`

    LoginScreen.js

`
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class LoginScreen extends React.Component {
  render() {
    return (
        <View>
     <Text> This is login Screen </Text>
     </View>
    );
  }
}
export default LoginScreen;`
Syed Zain Ali
  • 1,206
  • 1
  • 14
  • 20

2 Answers2

0

Using react-native, after you install a new package with npm install, you must run react-native link to update your node-modules folder. Then, if using android and if it is needed, you can run:

cd android && gradlew clean
cd .. & react-native run-android

Also, your code presents some syntax errors in imports. Fix ; in end lines and the { at line 3.

Taylon Assis
  • 332
  • 1
  • 6
  • 16
  • Hi thank you for replying, I tried your solution but i am still getting the same error :( – Mehreen Khan Apr 14 '18 at 13:00
  • Have you checked within node-modules folder if the react-navigation is in there? You can also check in your package.json file – Taylon Assis Apr 14 '18 at 13:16
  • Hi, thank you so much for pointing out that. I assumed by running `npm install --save react-navigation` will automatically do that job. – Mehreen Khan Apr 14 '18 at 14:07
0

Check NativeBase Docs. Installation for RN, Expo and web app are documented clearly.

Also check https://reactnativeseed.com/ for working examples

Supriya Kalghatgi
  • 1,155
  • 9
  • 10