Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Transpiling with Standalone Babel CLI

Invalid configuration object when running npm run build with webpack 2.2.1

How to migrate this from webpack 1 to webpack 2?

3 Answers

I don't know the details about migrating from webpack 1 to 2, but it seems that the "excludes" property that Isaac Lee puts in the webpack.config.js file at 3:32 in the video, changed to "exclude"(singular instead of plural). That small change made everything work for me.

webpack.config.js

var webpackConfig = {
  entry: "./src/index.js",
  output: {
    path: __dirname + "/build",
    filename: "index.js"
  },
  module: {
    loaders: [
        {
            loader: "babel-loader",
            test: /.js$/,
            exclude: /node_modules/
        } 
    ]
  }
};

module.exports = webpackConfig;
Oziel Perez
Oziel Perez
61,321 Points

As of webpack 2.0, "loaders" should be renamed to "rules" and "excludes" should be "exclude". Check which version of webpack you installed by looking at your package.json file and change accordingly.

Allen Johnson
Allen Johnson
7,417 Points

Thank you! Making both of these updates together resolved the issues I was having.

Jamie Lynn
Jamie Lynn
13,003 Points

Works great!!! Thank you Oziel Perez!

Michael Liendo
Michael Liendo
15,326 Points

Best step is to view the webpack docs/guides: https://webpack.js.org/guides/ In case you've followed their docs in the past, rest assured, the docs in V2 are pretty well written ;)

Here are their steps for migrating: https://webpack.js.org/guides/migrating/