title: Sharing constants between a web client and NodeJS server
body: <p>I have a NodeJS application with common constants between the client and the server.</p>
  
  <p>The constants are stored in variables rather than inline.  Those variables could be defined in two separate files, one for client and one for server.</p>
  
  <p><strong>File 1:</strong> </p>
  
  <pre><code>// client_constants.js
  MESSAGE_TYPE_A = "a";
  MESSAGE_TYPE_B = "b";
  </code></pre>
  
  <p><strong>File 2:</strong></p>
  
  <pre><code>// server_constants.js
  exports.MESSAGE_TYPE_A = "a";
  exports.MESSAGE_TYPE_B = "b";
  </code></pre>
  
  <p>To avoid duplicate code I would like to store constants in a single location and a single format for both the client and the server.  Wat do?</p>