N
N
Nick Nesterov2016-05-09 11:36:07
Express.js
Nick Nesterov, 2016-05-09 11:36:07

Express doesn't load React's bundel.js, what's wrong?

After running Express, the front-end does not load and the error "Uncaught SyntaxError: Unexpected token <" is displayed in the console.
Please tell me what is wrong!
I load the frontend in this way:
app.use(express.static('./client'));
Here is my webpack config:

var webpack = require('webpack');
var path = require('path');

module.exports = {
    devtool: "source-map"
    entry: "./client/main.js",
    output: {
        path: path.resolve(__dirname, 'public/build'),
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: [/node_modules/, /public/],
                loader: 'babel',
                query: {
                  presets:['es2015', 'react']
                }
            },
            {
                test: /\.jsx$/,
                exclude: [/node_modules/, /public/],
                loader: 'babel',
                query: {
                  presets:['es2015', 'react']
                }
            },
            {
              test: /\.css$/,
              exclude: [/node_modules/, /public/],
              loaders: ['style', 'css']
            },
            {
              test: /\.scss$/,
              exclude: [/node_modules/],
              loaders: ["style", "css?sourceMap", "sass?sourceMap"]
            }
        ]
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2016-05-09
@njnesterov

You most likely specified the wrong path to the file. Read more here (read the whole section, it's short).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question