title: Attempting to Import Module in Child Process (Javascript) and Failing
body: <p>I'm currently running a heavy computation (i.e. generating a Monte Carlo tree), which is an expensive operation. I only have a few seconds to build as big of a tree as I can, so I am using subprocesses in Node.js in order to build multiple trees, and then aggregate their data together to make a more informed decision.</p>
  
  <p>I understand that subprocesses do not share information/memory, and I need to use modules within these subprocesses that are located in a file, called "Epilog.js" on my machine.</p>
  
  <p>When I run functions that are in epilog.js from the main file, it works just fine. But all of my functions that are in my worker threads return absolutely nothing.</p>
  
  <p>I have tested to make sure that the parameters of the functions I am trying to use in "epilog.js" aren't empty, and they're not. The problem isn't in the parameter.</p>
  
  <p>I have also tested to see what happens if I simply don't import, and instead of just outputting an undefined array, I get an error saying that there is no function called "findroles".</p>
  
  <pre><code>//My main thread.
  var fs = require('fs');
  eval(fs.readFileSync('epilog.js') + '');
  
  var process = fork('./buildGraph.js');
  process.send({library});
  
  </code></pre>
  
  <pre><code>//My worker thread.
  //buildGraph.js
  
  var fs = require('fs');
  eval(fs.readFileSync('epilog.js') + '');
  
  // receive message from master process
  process.on('message', async(message) =&gt; {
    library = message["library"];
    console.log(findroles(library)); 
  // findroles(library) is a function that is defined in epilog.js, 
  //and this outputs an array of "roles" given a parameter,library. 
  // For some reason this function outputs [], rather than giving me 
  // all of the roles. If I run this exact line from my main thread, 
  // it doesn't give any errors and outputs the right array: 
  // e.g. ['red', 'white']. 
  });
  
  </code></pre>
  
  <p>I expect to get not the empty array, but [red, white], as I do if I were to run the same line in the main thread. Does anyone have an idea as to the inconsistency of the functions? I'm very new to node.js and this isn't a class focused too much on software engineering in JavaScript, so I'd appreciate if someone can dumb down what is going on, as this is all very new to me.</p>