title: How to include a file which is not a module in Node.js (to make a module of it)?
body: <p><strong>Purpose</strong>: making a Node.js module or a Requirejs AMD module, from a plain old JavaScript file like this:</p>
  
  <pre><code>var foo = function () {};
  </code></pre>
  
  <p>I have <strong>no control and I can't edit</strong> <code>foo.js</code>.</p>
  
  <p>Why<code>foo</code> is is a plain empty object inside the first <code>if</code>? How can I "include" a plain JavaScript file in my module? File <code>mymodule.js</code>:</p>
  
  <pre><code>(function(root) {
      if(typeof exports === 'object') { // Node.js
          var foo = require('./foo');
  
          console.log(foo); // { }
      } else if (typeof define === 'function' &amp;&amp; define.amd) { // RequireJS AMD
          define(['foo'], function () {
              return foo;
          });
      }
  }());
  </code></pre>