-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Loading ES6 modules --experimental-modules #19325
Comments
your files with es module syntax in them will need to be named with .mjs not .js |
https://nodejs.org/api/esm.html#esm_enabling
Upd: I was late by a second :-). |
I changed my entry file to be
|
this was fixed on node 9.8.0 |
Too experimental.... switching back to require... |
@Legends That is intended to be that way and does not come from the «experimental» stability level 😉. |
Yeah, I had a |
@Legends the future isn't 100% known yet, you can follow along at https://github.com/nodejs/modules. |
Actually, the doc says you can avoid naming with .mjs if you have a package.json appropriately configured nearby:
This worked for me at:
I just added a package.json in the same folder as my script like this:
I ran my script with the |
Works fine with
require
.Trying to use ES6 module
import
format in node.js application, but getting errors:launch.json:
ModulesFile.js
export class X...
export class Y ...
Index.js
import X from"../samples/ModulesFile";
Result:
The text was updated successfully, but these errors were encountered: