Unable to require('child_process').spawn, console says spawn is not a function, Python-Shell node package
<p>I am attempting to use an external package:</p>

<pre><code>npm install [python-shell][1]
</code></pre>

<p>Right now, I have just the basic js file with the example the package comes with:</p>

<pre><code>console.log('hey in main.js')
var PythonShell = require('python-shell');

PythonShell.run('./my_script.py', function (err) {
  if (err) throw err;
  console.log('finished running python script');
});
</code></pre>

<p>Along with <code>my_script.py</code>, etc</p>

<p>When I start up the server, the console.log says:</p>

<pre><code>Uncaught TypeError: spawn is not a function
</code></pre>

<p>Within the index.js of the python-shell package, spawn is required correctly (<a href="https://github.com/amir20/phantomjs-node/issues/173" rel="nofollow noreferrer">similar case</a>):</p>

<pre><code>var spawn = require('child_process').spawn;
</code></pre>

<p>And later, it is used in the package like so:</p>

<pre><code>this.childProcess = spawn(pythonPath, this.command, options);
</code></pre>

<p>However, <code>spawn</code> does seem to be a function:</p>

<pre><code>master$&gt;node
&gt; require('child_process')
{ ChildProcess: 
   { [Function: ChildProcess]
     super_: 
      { [Function: EventEmitter]
        EventEmitter: [Circular],
        usingDomains: true,
        defaultMaxListeners: 10,
        init: [Function],
        listenerCount: [Function] } },
  fork: [Function],
  _forkChild: [Function],
  exec: [Function],
  execFile: [Function],
  spawn: [Function],
  spawnSync: [Function: spawnSync],
  execFileSync: [Function: execFileSync],
  execSync: [Function: execSync] }
</code></pre>

<p>So I'm not sure why console says it is not a function.</p>