title: Unexpected token export when running Terminal App
body: <p>This seems like just a normal module and export, not sure what's causing this.</p>
  
  <p><strong>myES6Module.js</strong></p>
  
  <pre><code>const showCar = () =&gt; {
     //...code
  }
  
  const drive = () =&gt; {
    //...code
  };
  
  drive();
  
  export { drive, showCar }
  </code></pre>
  
  <p>What's weird is in <strong>my tests I'm able to import and call these just fine and my tests use them and pass</strong>.  But <strong>when I actually run the drive()</strong> which runs the app by prompting the user for terminal input, I get an error saying:</p>
  
  <p><code>
  SyntaxError: Unexpected token export
      at new Script (vm.js:74:7)
      at createScript (vm.js:246:10)
      at Proxy.runInThisContext (vm.js:298:10)
      at Module._compile (internal/modules/cjs/loader.js:670:28)
  </code></p>
  
  <p>Why would this resolve just fine for test but not live running of the code?</p>
  
  <p><strong>Here's how I'm running it</strong>, a <strong>script</strong> in my <strong>package.json</strong>:</p>
  
  <pre><code>"start": "node --experimental-modules ./myES6Module.js"
  </code></pre>
  
  <p>so it's when I run <code>yarn start</code> I get this.  Otherwise, when I run my tests, drive() outputs to the console just fine.</p>
  
  <p><strong>if I comment out that exports, my script runs fine</strong>...but of course that breaks my tests which rely on exporting stuff.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I'm using <code>--experimental-modules</code></p>
  
  <p>So I tried this since I have babel-cli installed:</p>
  
  <pre><code>"start": "babel ./myES6Module.js"
  </code></pre>
  
  <p>package.json has the following babel packages:</p>
  
  <p><code>
      "@babel/cli": "^7.0.0-beta.51",
      "@babel/preset-env": "^7.0.0-beta.51",
      "@babel/register": "^7.0.0-beta.51",
      "@babel/core": "^7.0.0-beta.51",
  </code></p>
  
  <p>but that just console.logged the file content, it didn't run it.
  <strong>I don't want to use <code>--experimental-modules</code> either.</strong> I don't want to change my file extension so how do I get this running?</p>
  
  <p>I took a look at this and it mentions about migrating if you are already using babel-node but is that the only way?</p>
  
  <p><a href="https://babeljs.io/docs/en/next/v7-migration" rel="nofollow noreferrer">https://babeljs.io/docs/en/next/v7-migration</a></p>