title: Loading remote js file using require with node.js
body: <p>I've been working on an online socket server using NodeJS and javascript, and I've been creating "playrooms" in my code using require:</p>
  
  <pre><code>new_game_obj = require('./forza4.js');
  </code></pre>
  
  <p>Now.. this works find when I test my code on my local machine, but for the production server I've been presented with a problem. It would seem that for some technical reason, the process that runs my code is on a different machine then the one I have access to (for file uploading, and such), so I was asked by the guys on the server farm to change my code so that I will load the code I have in "forza4.js" from a global position, and not local, like I do at the moment.
  So I changed the code to this:</p>
  
  <pre><code>new_game_obj = require('http://www.xxxxx.com/blabla/forza4.js');
  </code></pre>
  
  <p>(Of course I tested to see if the file is there, just to be sure, it shows in the browser when I point to that actual address)
  But I get an error from my code (again, at this point, I'm running this locally on my machine), which says:</p>
  
  <blockquote>
    <p>Exception: Error: Cannot find module '<a href="http://www.xxxxx.com/blabla/forza4.js" rel="noreferrer">http://www.xxxxx.com/blabla/forza4.js</a>'</p>
  </blockquote>
  
  <p>So just to be on the safe side, I did:</p>
  
  <pre><code>new_game_obj = require('http://92.xx.xx.xx/blabla/forza4.js'); 
  </code></pre>
  
  <p>But again, the same error.</p>
  
  <p>Should there be a problem loading an "extension" to my code from a remote server, or am I just formatting the "require" call wrong?</p>
  
  <p>Thanks a bunch!</p>
  
  <p>Yuval.</p>
  
  <p>P.S.
  This is a follow up to this thread:
  <a href="https://stackoverflow.com/questions/22865361/create-a-copy-of-a-module-instead-of-an-instance-in-node-js">This is the older and resolved post</a></p>