I recently came back to Node.js after my brief exploration of front end, and have found that IO.js has merged back with Node.js. So I downloaded Node.js v4.4.2 and I wanted to mess around with ES6 modules, which I was doing before my aformentioned hiatus, I seem unable to use them.
I went to the Node.js website and found how to enable them (--harmony_modules
), and using that flag, I still got the following error:
main.js:1
(function (exports, require, module, __filename, __dirname) { import * from "lib/Tile"
^^^^^^
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
Am I doing something wrong here, or is there a bug in the Module Implementation? The involved files are posted below:
main.js:
import * from "lib/Tile"
console.log(Tile)
lib/Tile.js
export class Tile {
constructor(data = {}) {
this.data = data
}
}