title: requirejs, babelify and browserify when npm installing and building a module
body: <p>I have a problem with an npm module I've created. It's built using browserify and babelify.</p>
  
  <p>Here is a snippet from the <code>package.json</code>:</p>
  
  <pre><code>"name": "foo",
  "main": "index.js",
  "scripts": {
      "start": "watchify src/foo.js -t babelify -s foo -o ./index.js"
  }
  </code></pre>
  
  <p>Which is basically the entire build process (no minifying or anything). There are also some tests, which run without a problem.</p>
  
  <p>In <code>src/foo.js</code> I import other files, which are located in the same folder.</p>
  
  <pre><code>import bar from './bar';
  </code></pre>
  
  <p>So, the file structure looks something like:</p>
  
  <pre><code>index.js
  package.json
  src/
      foo.js
      bar.js
  </code></pre>
  
  <p>Now, when I install the module elsewhere, in a completely different project, and <code>import</code> it:</p>
  
  <pre><code>import foo from 'foo';
  </code></pre>
  
  <p>... and build the new project with</p>
  
  <pre><code>watchify src/app.js -d -t babelify -o js/app.js
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Error: Cannot find module './bar' from '[file_path]/node_modules/foo/'
  </code></pre>
  
  <p>So basically (as I understand it), it looks at the (now) <code>var bar = require('./bar');</code> and searches in the file path (the same folder) whereas, everything in reality was bundled into one file, everything included.</p>
  
  <p>What am I missing here? How do I build it correctly?</p>