title: Write javascript code that works with client side javascript and server side NodeJs modules
body: <p>Browserify and lo-dash, do something special. Ok, but should like to be free from other vendor libraries or nodejs modules. I want to write reusable code. So, ...</p>
  
  <p>I can write some javascript code. Also, I can write NodeJs code. Ok: I can write a module for NodeJs, for server-side code but at some point I need to write a NodeJs code to export, for example, a module.</p>
  
  <pre><code>var MyModule = function () {
      this.attribute = 666
  }
  module.exports = MyModule
  </code></pre>
  
  <p>But, ... it's a NodeJs module. If I try to include it in client page ...</p>
  
  <pre><code>&lt;script src="lib/myModule.js"&gt;
  </code></pre>
  
  <p>I'll get 'Uncaught ReferenceError: module is not defined'. Why? Maybe, because it's NodeJs code, and not Javascript. Ok but, ... Which are best practice to share same code in client and server side with NodeJs. Ok, I can share a javascript file, and use it in both sides. How can I write a module, that works with a javascript code, that I want to use also in client side?</p>
  
  <p>What I am looking for, is:</p>
  
  <p>Write some javascript code. <strong>my_public_file</strong>.js:</p>
  
  <pre><code>console.log('I am a javascript snippet')
  </code></pre>
  
  <p>Then, I want to write a module that works with same code. <strong>my_module</strong>.js</p>
  
  <pre><code>var lib_public_code = require('some/public/path/my_public_file.js')
  var MyModule = function () {
      this.attribute = 666
  }
  module.exports = MyModule
  </code></pre>
  
  <p>And, also, I wanto to write a public web page (<strong>index.html</strong>) that works with the same code</p>
  
  <pre><code>&lt;script src="javascript/my_public_file.js"&gt;
  </code></pre>
  
  <p>Best practices? I am insane?</p>