title: Best way to start main node app from simple script
body: <p>I'd like to start an app in two different ways depending on the environment.</p>
  
  <p>In package.json:</p>
  
  <pre><code>"scripts": {
      "start": "node start.js" 
  }
  </code></pre>
  
  <p>Then in the script  check the environment variable and execute the correct command:</p>
  
  <pre><code>// start.js
  var env = process.env.NODE_ENV;
  
  if (env === 'development') {
      //run './node_modules/.bin/nodemon main.js' 
  }
  
  if (env === 'production') {
      //run 'node main.js'
  }
  
  //do I need to exit?
  process.exit(1);
  </code></pre>
  
  <p>Is <code>exec</code>, <code>fork</code>, or <code>spawn</code> ideal here? I need no communication between start.js and the main.js, and I want the least overhead. I want it to be as close to running the environment specific command directly. My inclination is <code>fork</code> because it will start a new process and the parent will terminate.</p>
  
  <p><strong>UPDATE</strong>: I am not interested in alternative solutions that use multiple npm commands. I specifically want to understand the pros/cons/resource use/performance implications of starting one node script from another using the various <em>child_process</em> methods.</p>