title: How do I require a node module in my client side javascript?
body: <p>I am trying to build a natural language processing bot using javascript and jQuery for the logic and node and express as the framework. I discovered a natural language processing facility that would be extremely useful for my project <a href="https://github.com/NaturalNode/natural" rel="nofollow">https://github.com/NaturalNode/natural</a> unfortunately the documentation is sparse and I have only been using node for a couple of weeks.</p>
  
  <p>This is the code I have on my server side app.js  </p>
  
  <pre><code> var natural = require('natural'),
   tokenizer = new natural.WordTokenizer();
   stemmer.attach();
   var express = require("express");
   app = express();
   app.set("view engine", "ejs");
   app.use(express.static(__dirname + '/public'));
  </code></pre>
  
  <p>I am requiring the 'natural' module here but I am unable to use the methods that are outlined in the documentation. </p>
  
  <pre><code>var natural = require('natural'),
  tokenizer = new natural.WordTokenizer();
  console.log(tokenizer.tokenize("your dog has fleas."));
  // [ 'your', 'dog', 'has', 'fleas' ]
  </code></pre>
  
  <p>The method 'tokenizer' is undefined. I have done quite a bit of research on this and looked into using module.export and passing variables through the app.get function for the index.ejs page I am using but I have been unsuccessful so far.</p>
  
  <p>NOTE: The javascript file I am trying to use these methods in is located in the public/javascript directory while the app.js file is located in the main project directory. I have tried to require the 'natural' package directly in the javascript file I am trying to use the methods in but an error was thrown saying require is an undefined method. </p>
  
  <p>here is the package.json file:</p>
  
  <pre><code> {
    "name": "JSAIN",
    "version": "1.0.0",
    "description": "",
    "main": "app.js",
    "scripts": {
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
   },
    "author": "",
    "license": "ISC",
    "dependencies": {
    "ejs": "^2.3.1",
    "express": "^4.12.3",
    "natural": "^0.2.1",
    "underscore": "^1.8.2"
      }
    }
  </code></pre>