ES6 import statements not working in Node v8.4.0
One way that I have worked around this issue...
Install babel stuff for the project:
$ npm install babel-register babel-preset-es2015 --save-dev
Create an index.js file that is the main entry point into the app:
// index.js
// by requiring `babel/register`, all of our successive `require`s will be Babel'd
require('babel-register')({
presets: [ 'es2015' ]
});
require('./server');
Then, create a file called server.js that will have your normal index code:
// server.js
import express from 'express';
var app = express()
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(3000, () => console.log('Example app listening on port 3000!'))
And run:
$ node index.js