D
D
Dolerum2019-03-30 15:09:43
JavaScript
Dolerum, 2019-03-30 15:09:43

Why is there a Module parse failed error in webpack?

An error occurs.

``ERROR in ./jsx/app.jsx
Module parse failed: C:\ProjectCourse\здесь путь Unexpected token (6:7)
You may need an appropriate loader to handle this file type.
| import {articles} from './fixtures.js'
|
| render(<Article />, document.getElementById('container'))
| /*article = {articles[0]}*/
 @ multi ./jsx/app.jsx``

Webpack 2.6.1
Settings
var path = require('path')

module.exports = {
    devtool: 'source-map',
    entry: [
        './jsx/app.jsx'
    ],
    output: {
        path: path.join(__dirname, 'build'),
        filename: 'bundle.js',
        publicPath: '/build/'
    },
    devServer: {
        proxy: [{
            path: '/api/',
            target: 'http://localhost:3001'
        }],
        historyApiFallback: true
    },
    module: {
        loaders: [
            {
                test: /\.js/,
                loaders: ['babel-loader'],
                include: path.join(__dirname, 'src')
            },
            {
                test: /\.css/,
                loaders: ['style-loader', 'css-loader'],
            }
        ]
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-03-30
@rockon404

test: /\.js[x]?$/,
UPD: you have entry './jsx/app.jsx', but include . Carry the include. And use only the latest versions of libraries in projects. The current major version of Webpack is 4. path.join(__dirname, 'src')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question