I'm trying too run $npm run dev. but i end up with a unexpected token import error in the webpack.config.babel.js
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import autoprefixer from 'autoprefixer';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import ReplacePlugin from 'replace-bundle-webpack-plugin';
import OfflinePlugin from 'offline-plugin';
import path from 'path';
import V8LazyParseWebpackPlugin from 'v8-lazy-parse-webpack-plugin';
const ENV = process.env.NODE_ENV || 'development';
const CSS_MAPS = ENV!=='production';
module.exports = {
context: path.resolve(__dirname, "src"),
entry: './index.js',
output: {
path: path.resolve(__dirname, "build"),
publicPath: '/',
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.jsx', '.js', '.json', '.less'],
modulesDirectories: [
path.resolve(__dirname, "src/lib"),
path.resolve(__dirname, "node_modules"),
'node_modules'
],
alias: {
components: path.resolve(__dirname, "src/components"), // used for tests
style: path.resolve(__dirname, "src/style"),
'react': 'preact-compat',
'react-dom': 'preact-compat'
}
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
exclude: path.resolve(__dirname, 'src'),
loader: 'source-map-loader'
}
],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
// Transform our own .(less|css) files with PostCSS and CSS-modules
test: /\.(less|css)$/,
include: [path.resolve(__dirname, 'src/components')],
loader: ExtractTextPlugin.extract('style?singleton', [
`css-loader?modules&importLoaders=1&sourceMap=${CSS_MAPS}`,
`postcss-loader`,
`less-loader?sourceMap=${CSS_MAPS}`
].join('!'))
},
{
test: /\.(less|css)$/,
exclude: [path.resolve(__dirname, 'src/components')],
loader: ExtractTextPlugin.extract('style?singleton', [
`css-loader?sourceMap=${CSS_MAPS}`,
`postcss-loader`,
`less-loader?sourceMap=${CSS_MAPS}`
].join('!'))
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(xml|html|txt|md)$/,
loader: 'raw-loader'
},
{
test: /\.(svg|woff2?|ttf|eot|jpe?g|png|gif)(\?.*)?$/i,
loader: ENV==='production' ? 'file-loader' : 'url-loader'
}
]
},
postcss: () => [
autoprefixer({ browsers: 'last 2 versions' })
],
plugins: ([
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('style.css', {
allChunks: true,
disable: ENV!=='production'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(ENV)
}),
new HtmlWebpackPlugin({
template: './index.ejs',
minify: { collapseWhitespace: true }
}),
new CopyWebpackPlugin([
{ from: './manifest.json', to: './' },
{ from: './favicon.ico', to: './' }
])
]).concat(ENV==='production' ? [
new V8LazyParseWebpackPlugin(),
new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
},
compress: {
warnings: false,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
negate_iife: false
}
}),
// strip out babel-helper invariant checks
new ReplacePlugin([{
// this is actually the property name https://github.com/kimhou/replace-bundle-webpack-plugin/issues/1
partten: /throw\s+(new\s+)?[a-zA-Z]+Error\s*\(/g,
replacement: () => 'return;('
}]),
new OfflinePlugin({
relativePaths: false,
AppCache: false,
excludes: ['_redirects'],
ServiceWorker: {
events: true
},
cacheMaps: [
{
match: /.*/,
to: '/',
requestTypes: ['navigate']
}
],
publicPath: '/'
})
] : []),
stats: { colors: true },
node: {
global: true,
process: false,
Buffer: false,
__filename: false,
__dirname: false,
setImmediate: false
},
devtool: ENV==='production' ? 'source-map' : 'cheap-module-eval-source-map',
devServer: {
port: process.env.PORT || 8080,
host: 'localhost',
colors: true,
publicPath: '/',
contentBase: './src',
historyApiFallback: true,
open: true,
proxy: {
// OPTIONAL: proxy configuration:
// '/optional-prefix/**': { // path pattern to rewrite
// target: 'http://target-host.com',
// pathRewrite: path => path.replace(/^\/[^\/]+\//, '') // strip first path segment
// }
}
}
};
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Ggzingeest\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle [email protected]~predev: [email protected]
6 silly lifecycle [email protected]~predev: no script for predev, continuing
7 info lifecycle [email protected]~dev: [email protected]
8 verbose lifecycle [email protected]~dev: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~dev: PATH: C:\Users\Ggzingeest\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\Users\Ggzingeest\Documents\Git\Preact\tablet-registratie\node_modules\.bin;C:\Perl64\site\bin;C:\Perl64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Android\platform-tools;C:\Windows\System32;C:\Program Files\Git\cmd;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\nodejs\;C:\Perl64\site\bin;C:\Perl64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Android\platform-tools;C:\Windows\System32;C:\Program Files\Git\cmd;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\nodejs\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Android\platform-tools;C:\Windows\System32;C:\Python27\;C:\Python27\Scripts\;C:\Users\Ggzingeest\AppData\Local\Microsoft\WindowsApps;C:\Users\Ggzingeest\AppData\Local\atom\bin;C:\Users\Ggzingeest\AppData\Roaming\npm;c:\Users\Me\AppData\Roaming\npm\
10 verbose lifecycle [email protected]~dev: CWD: C:\Users\Ggzingeest\Documents\Git\Preact\tablet-registratie
11 silly lifecycle [email protected]~dev: Args: [ '/d /s /c',
11 silly lifecycle 'cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress' ]
12 silly lifecycle [email protected]~dev: Returned: code: 1 signal: null
13 info lifecycle [email protected]~dev: Failed to exec dev script
14 verbose stack Error: [email protected] dev: `cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Users\Ggzingeest\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:194:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Users\Ggzingeest\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:194:7)
14 verbose stack at maybeClose (internal/child_process.js:899:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd C:\Users\Ggzingeest\Documents\Git\Preact\tablet-registratie
17 verbose Windows_NT 10.0.14393
18 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Ggzingeest\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
19 verbose node v7.9.0
20 verbose npm v4.5.0
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] dev: `cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress`
23 error Exit status 1
24 error Failed at the [email protected] dev script 'cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the tablet-registratie package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress
24 error You can get information on how to open an issue for this project with:
24 error npm bugs tablet-registratie
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls tablet-registratie
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]