title: Can not Use Node, Mocha & Babel@7.x.x Together
body: <p>I've Installed Node@10.x.x, Mocha@6.x.x &amp; Babel@7.x.x. I'm trying to run some mocha tests in ES6 standard with running <code>npm test</code> but I get the following error:</p>
  
  <pre><code>&gt; test@1.0.0 test G:\Ebooks\16 [Test]\test2
  &gt; mocha --require @babel/register
  G:\Ebooks\16 [Test]\test2\test\index.spec.js:1
  
      (function (exports, require, module, __filename, __dirname) { import { expect } 
  from "chai";
  SyntaxError: Unexpected token {
  at new Script (vm.js:79:7)
  at createScript (vm.js:251:10)
  at Object.runInThisContext (vm.js:303:10)
  at Module._compile (internal/modules/cjs/loader.js:657:28)
  at Module._compile (G:\Ebooks\16 [Test]\test2\node_modules\pirates\lib\index.js:99:24)
  at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
  at Object.newLoader [as .js] (G:\Ebooks\16 [Test]\test2\node_modules\pirates\lib\index.js:104:7)
  at Module.load (internal/modules/cjs/loader.js:599:32)
  at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
  at Function.Module._load (internal/modules/cjs/loader.js:530:3)
  at Module.require (internal/modules/cjs/loader.js:637:17)
  at require (internal/modules/cjs/helpers.js:22:18)
  at G:\Ebooks\16 [Test]\test2\node_modules\mocha\lib\mocha.js:330:36
  at Array.forEach (&lt;anonymous&gt;)
  at Mocha.loadFiles (G:\Ebooks\16 [Test]\test2\node_modules\mocha\lib\mocha.js:327:14)
  at Mocha.run (G:\Ebooks\16 [Test]\test2\node_modules\mocha\lib\mocha.js:804:10)
  at Object.exports.singleRun (G:\Ebooks\16 [Test]\test2\node_modules\mocha\lib\cli\run-helpers.js:207:16)
  at exports.runMocha (G:\Ebooks\16 [Test]\test2\node_modules\mocha\lib\cli\run-helpers.js:300:13)
  at Object.exports.handler.argv [as handler] (G:\Ebooks\16 [Test]\test2\node_modules\mocha\lib\cli\run.js:296:3)
  at Object.runCommand (G:\Ebooks\16 [Test]\test2\node_modules\yargs\lib\command.js:242:26)
  at Object.parseArgs [as _parseArgs] (G:\Ebooks\16 [Test]\test2\node_modules\yargs\yargs.js:1104:24)
  at Object.parse (G:\Ebooks\16 [Test]\test2\node_modules\yargs\yargs.js:566:25)
  at Object.exports.main (G:\Ebooks\16 [Test]\test2\node_modules\mocha\lib\cli\cli.js:63:6)
  at Object.&lt;anonymous&gt; (G:\Ebooks\16 [Test]\test2\node_modules\mocha\bin\_mocha:10:23)
  at Module._compile (internal/modules/cjs/loader.js:689:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
  at Module.load (internal/modules/cjs/loader.js:599:32)
  at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
  at Function.Module._load (internal/modules/cjs/loader.js:530:3)
  at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
  at startup (internal/bootstrap/node.js:283:19)
  at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
  npm ERR! Test failed.  See above for more details.
  </code></pre>
  
  <p>It seems that Babel does not convert ES6 files. My package.json file is:</p>
  
  <pre><code>{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
      "test": "./node_modules/.bin/mocha ---require @babel/register"
  },
  "devDependencies": {
      "@babel/cli": "^7.4.3",
      "@babel/core": "^7.4.3",
      "@babel/node": "^7.2.2",
      "@babel/preset-env": "^7.4.3",
      "@babel/register": "^7.4.0",
      "chai": "^4.2.0",
      "mocha": "^6.1.0",
      "nodemon": "^1.18.10"
  }
  }
  </code></pre>
  
  <p>and my .babelrc is:</p>
  
  <pre><code>{
  "presets": ["@babel/preset-env"]
  
  }
  </code></pre>
  
  <p>Can anyone help me with this error?</p>
  
  <p>test file is ./test/index.spec.js: </p>
  
  <pre><code>import { expect } from "chai"
  import sayHello from "../src/index"
  
  describe("index test", () =&gt; {
  describe("sayHello function", () =&gt; {
      it("should say Hello guys!", () =&gt; {
  
          const str = sayHello();
          expect(str).to.equal("Hello guys!")
      })
  })
  })
  </code></pre>
  
  <p>&amp; .src/index.js is:</p>
  
  <pre><code>const sayHello = _ =&gt; "Hello guys!"
  
  console.log(sayHello())
  
  export default sayHello
  </code></pre>
  
  <p>This is the link of tutorial i followed it's instruction:
  <a href="https://dev.to/bnorbertjs/my-nodejs-setup-mocha--chai-babel7-es6-43ei" rel="nofollow noreferrer">https://dev.to/bnorbertjs/my-nodejs-setup-mocha--chai-babel7-es6-43ei</a></p>
  
  <p>i changed the package.json a little because --compiler is deprecated and does not work anymore.</p>