Tje123
Tje123

Reputation: 751

Unable to resolve module `react-native-router-flux'

I'm using react-native-router-flux in my react-native android project.

when I run my project, its showing below error on my emulator.

enter image description here

OS : Ubuntu 16.04

index.android

import React, { Component } from 'react';
import {AppRegistry,StyleSheet,Text,View,Image} from 'react-native';
import {Scene, Router} from 'react-native-router-flux';

import Movie from './src/view/Movies';


export default class testreact extends Component {
  render() {
      return
      <Router >
        <Scene key="root">
            <Scene key="Movie" component={Movie} title="Movie"/>
        </Scene>
    </Router>
  }
}

AppRegistry.registerComponent('testreact', () => testreact);

Movies

import React, {Component} from 'react';
import {AppRegistry, StyleSheet,Text, View,Image} from 'react-native';
import styles from './../res/styles/style';

var MOCKED_MOVIES_DATA = [
    {title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}},
];
class Movies extends Component {
    render() {
       var movie = MOCKED_MOVIES_DATA[0];
        return (
            <View style={styles.container}>
                <Text>Title : {movie.title}</Text>
                <Text>Year : {movie.year}</Text>
                <Image source={{uri:movie.posters.thumbnail}} style={styles.thumbnail}/>
            </View>
        );
    }
}

export default Movies;

Upvotes: 1

Views: 7066

Answers (4)

Mohd Qasim
Mohd Qasim

Reputation: 1020

seems you not downloaded that library please download by following command

npm i react-native-router-flux

syntax is npm i <library name>

Upvotes: 0

Wanda Ichsanul Isra
Wanda Ichsanul Isra

Reputation: 2292

I started facing this issue and performing the following steps resolved the problem:

  1. Change the version of your react-native-router-flux to 3.40.1
  2. Remove your node_modules directory (rm -rf node_modules)
  3. Run npm install

Upvotes: 5

Jeffrey
Jeffrey

Reputation: 4650

The problem will on the import styles from './../res/styles/style'; in Movies component replace the above code like this import styles from '../res/styles/style';

Upvotes: 0

Saravana Kumar
Saravana Kumar

Reputation: 3396

Use this command : npm i react-native-router-flux --save

Upvotes: 6

Related Questions