title: Client on Node.js: Uncaught ReferenceError: require is not defined
body: <p>I am writing an application with the Node.js, Express.js, and <a href="https://en.wikipedia.org/wiki/Jade_(disambiguation)#Technology" rel="noreferrer">Jade</a> combination.</p>
  <p>I have file <code>client.js</code>, which is loaded on the client. In that file I have code that calls functions from other JavaScript files. My attempt was to use</p>
  <pre><code>var m = require('./messages');
  </code></pre>
  <p>in order to load the contents of <code>messages.js</code> (just like I do on the server side) and later on call functions from that file. However, <code>require</code> is not defined on the client side, and it throws an error of the form <code>Uncaught ReferenceError: require is not defined</code>.</p>
  <p>These other JavaScript files are also loaded at runtime at the client, because I place the links at the header of the webpage. So the client knows all the functions that are exported from these other files.</p>
  <p>How do I call these functions from these other JavaScript files (such as <code>messages.js</code>) in the main <code>client.js</code> file that opens the socket to the server?</p>