Reputation: 1498
My application depends on library which uses ecma6 syntax for modules:
require lib = 'lib.js' // myapp.js
import Foo from 'bar' // lib.js
...
I want to run node myapp.js
, but it results in syntax error, since node does not support ecma6 modules (and --experimental-modules
would require lib.js
to be named lib.mjs
).
Is there any way to run myapp.js
without changing the source code of lib.js
?
Upvotes: 2
Views: 54
Reputation: 1336
look at https://babeljs.io/, you can compile your code (with that lib) to usual format
Upvotes: 2