title: Trying ES6 style import gives 'Cannot use import statement outside a module'
body: <p>I am trying to write a javascript test in intellij for which I need to import some dependancies and I want to use ES6 style import statements but getting error</p>
  <pre class="lang-sh prettyprint-override"><code>/usr/local/bin/node /workspace/rr-sample/node_modules/mocha/bin/_mocha
  --ui bdd --reporter &quot;/Users/me/Library/Application Support/IntelliJIdea2019.1/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js&quot;
  tests/*.test.js /workspace/rr-sample/tests/App.test.js:3
  import chai from 'chai'
  ^^^^^^
  
  SyntaxError: Cannot use import statement outside a module
      at wrapSafe (internal/modules/cjs/loader.js:1043:16)
      at Module._compile (internal/modules/cjs/loader.js:1091:27)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
      at Module.load (internal/modules/cjs/loader.js:976:32)
      at Function.Module._load (internal/modules/cjs/loader.js:884:14)
      at Module.require (internal/modules/cjs/loader.js:1016:19)
      at require (internal/modules/cjs/helpers.js:69:18)
      at /workspace/rr-sample/node_modules/mocha/lib/mocha.js:334:36
      at Array.forEach (&lt;anonymous&gt;)
      at Mocha.loadFiles (/workspace/rr-sample/node_modules/mocha/lib/mocha.js:331:14)
      at Mocha.run (/workspace/rr-sample/node_modules/mocha/lib/mocha.js:809:10)
      at Object.exports.singleRun (/workspace/rr-sample/node_modules/mocha/lib/cli/run-helpers.js:108:16)
      at exports.runMocha (/workspace/rr-sample/node_modules/mocha/lib/cli/run-helpers.js:142:13)
      at Object.exports.handler (/workspace/rr-sample/node_modules/mocha/lib/cli/run.js:292:3)
      at Object.runCommand (/workspace/rr-sample/node_modules/yargs/lib/command.js:242:26)
      at Object.parseArgs [as _parseArgs] (/workspace/rr-sample/node_modules/yargs/yargs.js:1087:28)
      at Object.parse (/workspace/rr-sample/node_modules/yargs/yargs.js:566:25)
      at Object.exports.main (/workspace/rr-sample/node_modules/mocha/lib/cli/cli.js:68:6)
      at Object.&lt;anonymous&gt; (/workspace/rr-sample/node_modules/mocha/bin/_mocha:10:23)
      at Module._compile (internal/modules/cjs/loader.js:1121:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
      at Module.load (internal/modules/cjs/loader.js:976:32)
      at Function.Module._load (internal/modules/cjs/loader.js:884:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
      at internal/main/run_main_module.js:17:47
  
  </code></pre>
  <p>What exactly is the issue? I found this link (and others) <a href="http://xahlee.info/js/js_import_export.html" rel="noreferrer">http://xahlee.info/js/js_import_export.html</a> which tells you how to fix this error but in another context which doesn't help me, and it doesn't explain what the problem is.</p>
  <p>In case it is helpful here is the code I am using.</p>
  <pre><code>//const chai = require(&quot;chai&quot;);
  import chai from 'chai'
  
  const React = require(&quot;react&quot;);
  const expect = chai.expect;
  
  describe('how it works first-time test', () =&gt; {
    it('checks equality', () =&gt; {
  
      const val = false;
      expect(val).to.be.false;
    });
  
  });
  </code></pre>