Using Import In NodeJS server : <p>At the moment all my module in my nodejs server are imported as require() ie:</p>

<pre><code>let path = require('path');
let express = require('express');
let http = require('http');
let app = express();
</code></pre>

<p>However the tutorial I am following shows them imported as:</p>

<pre><code>import express from 'express'
import path from 'path'
</code></pre>

<p>Which throws the error:</p>

<pre><code>SyntaxError: Unexpected token import
</code></pre>

<p>My webpack.config.js is set up as:</p>

<pre><code>module: {
    rules: [
        {
            test: /\.js?$/,
            use: 'babel-loader',
            exclude: /node_modules/
        }
    ]
}
</code></pre>

<p>In bablerc:</p>

<pre><code>{
  "presets": ["es2015", "react"]
}
</code></pre>

<p>My package versions:</p>

<pre><code>   "babel-core": "^6.7.6",
    "babel-loader": "^6.2.4",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.5.0",

   "react": "^15.0.1",

  "devDependencies": {
    "babel-cli": "^6.18.0",
    "babel-preset-env": "0.0.3",
    "webpack": "^2.2.1",
    "webpack-dev-middleware": "^1.10.1",
    "webpack-dev-server": "^2.4.1",
    "webpack-hot-middleware": "^2.17.1"
  }
</code></pre>

<p>Import works in all my react components files, just not server.js. How do I switch my server over to Import from require?</p>
