title: Uncaught Error: Cannot find module "react"
body: <p>starting with, i am a beginner in React with Rails and trying things out. I am currently working with routing and i'm not sure where i'm going wrong. Please guide me.</p>
  
  <p>I have a container folder with UserWorld.jsx file. Its content are as follows:</p>
  
  <pre><code>import React, { PropTypes } from 'react';
  import User from '../containers/User';
  
  // Simple example of a React "smart" component
  export default class UserWorld extends React.Component {
    constructor(props, context) {
      super(props, context);
      // How to set initial state in ES6 class syntax
      // https://facebook.github.io/react/docs/reusable-components.html#es6-classes
      this.state = { users: this.props.data
      };
    }
    render() {
      var userNodes = this.state.users.map(function(user) {
        return (
            &lt;User key={user.id} first_name={user.first_name} last_name={user.last_name} email={user.email} city={user.city} address={user.address} /&gt;
        );
      });
      return (
        &lt;table&gt;
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;td&gt;First Name&lt;/td&gt;
              &lt;td&gt;Last Name&lt;/td&gt;
              &lt;td&gt;Email&lt;/td&gt;
              &lt;td&gt;Address&lt;/td&gt;
              &lt;td&gt;City&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
            {userNodes}
          &lt;/tbody&gt;
        &lt;/table&gt;
      );
    }
  }
  </code></pre>
  
  <p>Now, i wish to add a link and i'm including </p>
  
  <p><code>import { Router, Route, Link, browserHistory, IndexRoute  } from 'react-router'</code></p>
  
  <p>However this gives me an error in the console as follows:</p>
  
  <pre><code>Uncaught Error: Cannot find module "react"
  Exception in rendering!
  message: Could not find component registered with name UserWorldApp. Registered component names include [ HelloWorldApp ]. Maybe you forgot to register the component?
  </code></pre>
  
  <p>Now i have no clue about whats happening here. I would be obliged if someone could help me out here. Also, if i can get references for the same. I am facing trouble with the different syntax that are found all around.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I see that the error is appearing in the <code>var _react = require('react');</code> line in the Router.js in react-router folder in the node_modules folder.</p>
  
  <p>I get this in console:</p>
  
  <pre><code>ERROR in ../~/react-router/lib/Router.js
  18:03:09 client.1 | Module not found: Error: Cannot resolve module 'imports' in /Users/c193/Documents/React/test-react-on-rails/node_modules/react-router/lib
  18:03:09 client.1 |  @ ../~/react-router/lib/Router.js 19:13-29
  </code></pre>
  
  <p>P.S: All the docs and articles i read are way too technical for me to understand and i only understand bits and pieces of it. Its just been two weeks since i started.</p>