title: How to use node modules with React Native
body: <p>I'm new to React Native and would like to use a node module inside the React Native app I'm playing around with.</p>
  
  <p>The node module I would like to add is this:
  <a href="https://www.npmjs.com/package/swisseph" rel="nofollow">https://www.npmjs.com/package/swisseph</a></p>
  
  <p>So I went inside the project folder and ran <code>npm install swisseph</code></p>
  
  <p>In the app source code I added this:</p>
  
  <pre><code>var swisseph = require ('swisseph');
  </code></pre>
  
  <p>I ran the project and I get this error:</p>
  
  <pre><code>Invariant Violation: Application AwesomeProject has not been registered.
  This is either due to a require() error during initialisation or failure to call AppRegistry.registerComponent.
  </code></pre>
  
  <p>How does one use node modules inside React Native?</p>
  
  <p>The index.io.js file has these code:</p>
  
  <pre><code>    /**
   * Sample React Native App
   * https://github.com/facebook/react-native
   */
  'use strict';
  
  var React = require('react-native');
  var swisseph = require ('swisseph');
  
  var {
    AppRegistry,
    StyleSheet,
    Text,
    View,
  } = React;
  
  var AwesomeProject = React.createClass({
    render: function() {
      return (
        &lt;View style={styles.container}&gt;
          &lt;Text style={styles.welcome}&gt;
            Welcome to React Native!
          &lt;/Text&gt;
          &lt;Text style={styles.instructions}&gt;
            To get started, edit index.ios.js
          &lt;/Text&gt;
          &lt;Text style={styles.instructions}&gt;
            Press Cmd+R to reload,{'\n'}
            Cmd+D or shake for dev menu
          &lt;/Text&gt;
        &lt;/View&gt;
      );
    }
  });
  
  var styles = StyleSheet.create({
    container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
      backgroundColor: '#F5FCFF',
    },
    welcome: {
      fontSize: 20,
      textAlign: 'center',
      margin: 10,
    },
    instructions: {
      textAlign: 'center',
      color: '#333333',
      marginBottom: 5,
    },
  });
  
  AppRegistry.registerComponent('AwesomeProject', () =&gt; AwesomeProject);
  </code></pre>