title: Getting Uncaught TypeError: fs.readdirSync is not a function when using Browserify with Nutritionix NodeJS client library
body: <p>I'm trying to build a demo app using Node and I keep getting <strong>Uncaught TypeError: fs.readdirSync is not a function</strong> error when trying to use the Nutrionix NodeJS Client Library (<a href="https://github.com/nutritionix/nodejs-client-library" rel="noreferrer">https://github.com/nutritionix/nodejs-client-library</a>) and Browserify. </p>
  
  <p>I'm following this tutorial <a href="http://www.sitepoint.com/getting-started-browserify/" rel="noreferrer">http://www.sitepoint.com/getting-started-browserify/</a> up to the <strong>Using the Browserify Output</strong> section but instead of of using Underscore and the code provided for main.js, I'm using the Nutritionix NodeJS client library and the following code in main.js: </p>
  
  <pre><code>var NutritionixClient = require('nutritionix');
  
  var nutritionix = new NutritionixClient({
      appId: '7c710fbd',
      appKey: 'a2f106128aa4b2ab81fd783fca5bf0ee'
      // debug: true, // defaults to false
  });
  </code></pre>
  
  <p>My HTML using Jade is the following: </p>
  
  <pre><code>doctype html
  html
    head
      title= title
      link(rel='stylesheet', href='/stylesheets/style.css')
    body
      block content
      script(src='javascripts/nutri.js')
      script(src='javascripts/main.js')
  </code></pre>
  
  <p>I use the following in the command line to build a new JavaScript file with the Nutritionix: </p>
  
  <pre><code>browserify public/javascripts/main.js -o public/javascripts/nutri.js
  </code></pre>
  
  <p>When I run this locally, in the console, I get <strong>Uncaught TypeError: fs.readdirSync is not a function</strong> in line 465 of nutri.js, which is the file made by Browserify. That line is fourth line in the following function: </p>
  
  <pre><code>function readDirp(path, excludeList) {
      var lib = {};
      var expand = new Expander(path);
      var files = fs.readdirSync(path).map(expand);
  
      files.forEach(function(file){
          if (excluded(file.name, excludeList) === false) {
              lib[file.name.split('.').shift()] = require(file.location);
          }
      });
  
      return lib;
  }
  </code></pre>
  
  <p>I'm not sure why I keep getting this error. When I go through the Browserify tutorial which I linked at the top, I have no problem getting the Browserified file to work. Please let me know if more information is needed from me and any help is greatly appreciated.</p>