Reputation: 6776
I am using Nodejs v9.0.0. I have to use Babel for transpiling the code into ES5 because if not transpiled it throws error unexpected token import
. So If anyone know how to use the real ES6 version in nodejs and which nodejs version. Please let me know.
Thanks
Upvotes: 0
Views: 923
Reputation: 5452
All es6 is supported by NodeJS since 8.10 version : look at the column NodeJS in the es6 compatibility array. Unforfunately the ES6 Module syntax is not supported or only with the flag experimental.
So you need to convert your ESModule in CJSModule. You can do it with the babel-plugin-transform-es2015-modules-commonjs plugin
In your .babelrc file :
"plugins": [
"transform-es2015-modules-commonjs"
]
If you use babel-register the transformation occurs when the file is required(imported)
Upvotes: 2