When use ES6 module feature like this
node --harmony_modules tmp/es6Test.js
it throw an error
import { stat, exists, readFile } from 'fs';
^^^^^^
SyntaxError: Unexpected token import
My node is the 4.0.0 version
Harmony modules aren't implemented yet, see https://nodejs.org/en/docs/es6/. As a rule of thumb, if a feature requires a flag to enable, expect it to be incomplete or broken.
Duplicate of #518, #2760 and probably others.
Just out of curiosity, why is there even a flag to enable support for an unsupported feature? If it does nothing, it's just confusing a lot of people who're expecting import statements to work...
@Alhadis It comes from a dependency -- V8.
Alright, well, that implies that V8 _does_ support modules to some extent, but any supported features that it exposes are inaccessible to NodeJS. Or am I wrong?
No it doesn't really support modules at this time. Not ES6 modules anyways.
There was some old "modules" code laying around in there and that flag enables it for testing. Or used to anyways.
On Nov 5, 2015, at 11:06 AM, John Gardner [email protected] wrote:
Alright, well, that implies that V8 does support modules to some extent, but any supported features that it exposes are inaccessible to NodeJS. Or am I wrong?
—
Reply to this email directly or view it on GitHub.
Most helpful comment
Just out of curiosity, why is there even a flag to enable support for an unsupported feature? If it does nothing, it's just confusing a lot of people who're expecting
importstatements to work...