80

I'm trying to build a project with webpack and react with this webpack config:

var path = require('path'); var webpack = require('webpack'); module.exports = { entry: [ 'babel-polyfill', './app/less/main.less', './app/main.js', 'webpack-dev-server/client?http://localhost:8080' ], output: { publicPath: '/', filename: 'dist/main.js' }, debug: true, devtool: 'source-map', module: { loaders: [ { test: /\.js$/, include: path.join(__dirname, 'app'), loader: 'babel-loader', query: { presets: ['react', 'es2015'] } }, { test: /\.less$/, loader: "style!css!autoprefixer!less" }, ] } }; 

I am sure I have the needed pm modules too and have webpack installed, however when running webpack I get:

Module build failed: ReferenceError: [BABEL] /Users/me/foo/app/main.js: Unknown option: foo/node_modules/react/react.js.Children 

Any ideas?

1
  • 1
    Can you also paste your main.js? Commented Nov 16, 2015 at 17:29

2 Answers 2

193

Sorry I forgot to install babel-preset-react:

$ npm install babel-preset-react --save-dev 
Sign up to request clarification or add additional context in comments.

3 Comments

Don't be sorry. Nowhere it's said this NPM package needs to be installed.
wait, why do you need that package? It installs flow support, which you may or may not be using. Is it that you need syntax-jsx?
Didn't fix it for me. Where does it say you have to install this?
0

I just wanted to add that I got the error after I uninstalled an old npm module I wasn't using in my project anymore. Which was weird because I wasn't using it anywhere - how could uninstalling something that isn't used anywhere cause an error?

Turns out that one of that modules sub-dependencies had babel-preset-react, which I had missed installing to my own project when I started it. Thus, uninstalling that package also uninstalled the critical babel-preset-react!

For over a year, my react app could compile thanks to another package's sub-dependency...


So yes, installing babel-preset-react solved the issue for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.