webpack-article icon indicating copy to clipboard operation
webpack-article copied to clipboard

ES2015 Import not recognized

Open Gut6 opened this issue 9 years ago • 3 comments

ERROR in ./src/index.js Module parse failed: [...]\webpack-article-master\src\index.js Line 1: Unexpected token You may need an appropriate loader to handle this file type. | import './styles.scss'; | | // If we have an anchor, render the Button component on it

Is it just me or what but when I install it and try to run webpack then it simply doesn't work. ;)

I know that it's not issue of this project but I wonder how did You managed to have it running properly?

Gut6 avatar Nov 11 '15 16:11 Gut6

Is this on master or at a specific commit?

Anahkiasen avatar Nov 11 '15 18:11 Anahkiasen

Master. I found a fix for it. In webpack.config.js I changed it to this:

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

and also npm installed babel-preset-es2015 and now I'm after first component from article and it passed that issue with import. Now I'm facing another issue but it's not topic for this place.

Gut6 avatar Nov 11 '15 19:11 Gut6

Ah no yes, that's because Babel 6 got out and so running npm install babel-loader will get it, whereas the article was written with Babel 5. Will need to update the article.

Anahkiasen avatar Nov 11 '15 19:11 Anahkiasen