Webpack Object # <Object> has no 'forEach' method

I'll start using react with babel using webpack but after running webpack -w

it doesn't work and show an error like

TypeError: Object #<Object> has no method 'forEach'

      

my webpack config

module.exports = {
    entry: "./app/components/Main.js",
    output: {
        filename: "public/bundle.js"
    },
    module: {
        loaders: {
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            loader: "babel-loader"
        }
    }
}

      

My Main.js answer file

var React = require('react');

var Main = React.createClass({

    render: function() {
        return (
            <div>
                Hello world!
            </div>
        )
    }
});

React.render(<Main />, document.getElementById('app'));

      

Please, can anyone work it out?

+3


source share


1 answer


we have to specify an array of loaders for loader objects



module.exports = {
    entry: "./app/components/Main.js",
    output: {
        filename: "public/bundle.js"
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                loaders: ["babel-loader"],
            }
      ],
    },

};

      

+5


source







All Articles