title: Error: cannot find module when testing with mocha
body: <p>I'm using <code>babeljs</code> to write an RPG engine library. I have two files:</p>
  
  <p><strong>dice.js</strong></p>
  
  <pre><code>import assert from 'assert';
  import Random from 'random-js';
  
  export default class Dice {
    constructor(maxNumber) {
      assert(typeof(maxNumber) === "number", "maxNumber must be a number");
  
      this._mt = Random.engines.mt19937();
      this.minNumber = 1;
      this.maxNumber = maxNumber;
    }
  
    makeThrow() {
      this._mt.autoSeed();
      return Random.integer(this.minNumber, this.maxNumber)(this._mt);
    }
  }</code></pre>
  
  <p><strong>throwManager.js</strong></p>
  
  <p><pre><code>import assert from 'assert';
  import Dice from 'dice';
  export default class ThrowManager {
    constructor(settings) {
      assert(settings.hasOwnProperty("numberOfDices"), "must set 'numberOfDices'");
      assert(settings.hasOwnProperty("maxNumberInDice"), "must set 'maxNumberInDice'");
      assert(settings.maxNumberInDice &lt;= 1, "must have at least 1 dice");
      this.settings = settings;
    }
    execute() {
      var throwResults = [];
      for (var d = 1; d &lt;= this.settings.numberOfDices; d++) {
        var dice = new Dice(this.settings.maxNumberInDice);
        throwResults.push(dice.makeThrow());
      };
      return throwResults;
    }
  }
  </pre></code></p>
  
  <p>When I test them with <code>mocha</code>, I do these imports:</p>
  
  <p><strong>tests.js</strong></p>
  
  <pre><code>var assert = require('assert');
  var Amzhen = require('../Amzhen.js');
  var random = require('random-js');
  //tests here...
  </code></pre>
  
  <p>Yet when I run the tests, I get this:</p>
  
  <pre><code>
  Error: Cannot find module 'dice'
      at Function.Module._resolveFilename (module.js:338:15)
      at Function.Module._load (module.js:280:25)
      at Module.require (module.js:364:17)
      at require (module.js:380:17)
      at Object.&lt;anonymous> (/home/joel/Amzhen.js/Amzhen.js:47:28)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Module.require (module.js:364:17)
      at require (module.js:380:17)
      at Object.&lt;anonymous> (/home/joel/Amzhen.js/test/tests.js:2:14)
  </code></pre>
  
  <p>Any ideas why the <code>dice</code> module isn't being found?</p>
  
  <p>I'm compiling the code with <code>babel src --out-file Amzhen.js &amp;&amp; mocha</code></p>