title: child_process module has not been loaded yet
body: <p>I'm looking into NodeJS for running a PowerShell script from my JavaScript script. This is the code I found online:</p>
  
  <pre><code>var spawn = require("child_process").spawn,child;
  
  child = spawn("powershell.exe",["c:\\test\\mypstest.ps1 -arg1 1"]);
  
  child.stdout.on("data",function(data){
      console.log("Powershell Data: " + data);
  });
  
  child.stderr.on("data",function(data){
      console.log("Powershell Errors: " + data);
  });
  
  child.on("exit",function(){
     console.log("Powershell Script finished");
  });
  
  child.stdin.end(); //end input
  </code></pre>
  
  <p>When I run a live server on the html, I get the following console error:</p>
  
  <pre><code>Uncaught Error: Module name "child_process" has not been loaded yet for context: _. Use require([])
  </code></pre>
  
  <p>When I change</p>
  
  <pre><code>var spawn = require("child_process").spawn,child;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>var spawn = require(["child_process"]).spawn,child;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Uncaught TypeError: spawn is not a function               index.js
  Uncaught Error: Script error for "child_process"          require.js
  </code></pre>
  
  <p>I was under the impression that <code>child_process.js</code> was included in the Node.js installation. How can I fix this?</p>