Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use ES6 modules in Node.js 8? [duplicate]

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?

like image 334
Emil Avatar asked Jul 28 '17 18:07

Emil


People also ask

Can I use ES6 modules in 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.

How can ECMAScript modules be used natively in node?

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.

Does Nodejs support ECMAScript 6?

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.


1 Answers

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.

like image 88
AnilRedshift Avatar answered Oct 04 '22 15:10

AnilRedshift