Can I use ES6 module syntax with Node.js starting from version 8? Similar questions have already been asked on this site, but answers there are obsolete. I wonder if the situation has changed with new version of Node.js?
The syntax for importing modules in ES6 looks like this. The reason for this error is that Node js doesn't support ES6 import directly. If you try to use import for importing modules directly in node js it will throw out that error.
Authors can tell Node. js to use the ECMAScript modules loader via the . mjs file extension, the package. json "type" field, or the --input-type flag.
With regards to your second question, yes, there is es6-module-loader. For a long list of transpilers, shims, and other tools for using full ES6 features now, see addyosmani's ECMAScript 6 Tools page. As for native ES6 support in node.
https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c
It is in progress but the ETA is 2018 at the earliest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With