Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected token export webpack

I have webpack config like this:

loaders: [
    {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
    }
]

And babel config:

{
    "presets": ['es2015'],
    "plugins": ['transform-runtime']
}

But the browser shows this message:

Uncaught SyntaxError: Unexpected token export

What is wrong?

like image 290
djkah11 Avatar asked Oct 23 '16 12:10

djkah11


People also ask

How do I fix unexpected token export?

To solve the "Uncaught SyntaxError Unexpected token 'export'", refactor your code to use the CommonJS syntax, e.g. module. exports = {num}; instead of export num = 10; . Copied!


1 Answers

If you are using webpack 2 loaders become rules

like image 62
abdoutelb Avatar answered Oct 03 '22 16:10

abdoutelb