3

I am new to React+Webpack. As a part of the tutorial, I have written a webpack.config.js file. This is the file content:

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

module.exports = {
    devtool: 'inline-source-map',
    entry: [
        'webpack-dev-server/client?http://localhost:8080/',
        'webpack/hot/only-dev-server',
        './src'
    ],
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'bundle.js'
    },
    resolve:{
        moduleDirectories: ['node_modules', 'src'],
        extensions: ['', '.js']
    }
    module:{
        loaders:[
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loaders: ['react-hot','babel?presets[]=react,presets[]=es2015']
            }
        ]
    },
    plugins:[
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin()
    ]
};

I am getting Unexpected Identifier error at line number 19-> module:{...},

Error details:

/home/adi/testcode/webpack.config.js:19
    module:{
    ^^^^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at module.exports (/usr/lib/node_modules/webpack/bin/convert-argv.js:80:13)
    at Object.<anonymous> (/usr/lib/node_modules/webpack/bin/webpack.js:39:40)

I have checked webpack.config.js examples, and found what I wrote is correct. Yet it is not working as expected. Unfortunately, I couldn't find solution in GitHub issues, StackOverflow, and Quora.

Where am I making a mistake?

1 Answer 1

21

You forgot a comma before the module property

1
  • that's embarrassing :/ . Thank you for the help :)
    – CK5
    Commented Jan 19, 2017 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.