10
votes

I'm trying to transcompile my react/es6 code and am coming from browserify. I'm struggling to create a webpack build because of the new babel 6 release and the fact that most of the tutorials out there are now outdated. This works in my .babelrc:

{
  "presets": ["react"]
}

But when I change it to this:

{
  "presets": ["es2015", "react"]
}

it throws this cryptic error: ERROR in ./client/App.js Module build failed: Error: You gave us a visitor for the node type "NumericLiteral" but it's not a valid type

This is my webpack.config.js if that helps at all:

module.exports = {
  entry: "./client/App.js",
  output: {
    filename: "public/bundle.js"
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel'
      }
   ]
  }
};

Is there something obvious I'm missing? I've also swapped the order of the presets and it doesn't seem to make a difference. I have babel-core, babel-loader, babel-preset-es2015, babel-preset-react and webpack in my node modules.

4
Have you seen the troubleshoot section of the github repo?Rik

4 Answers

14
votes

I've had the same issue and it seems to have gone away after I removed the node_modules directory and reinstalled all the dependencies.

0
votes

I would start here if I were you. This will give you a very minimal template for React where you can reverse engineer and start learning how to use React inside of a webpack build. React Boilerplate This is very useful for getting started quick and easily, while learning webpack for what you will make use of it. I have always found the webpack documentation hard to figure out for what I need. I hope this helps.

0
votes

I solved this probleum by nvm even though i reinstalled by npm serveral times useless. I changed node version to 5+ then it will goes well althogh I already in 5+ node environment. that's imagine.

0
votes

I had the same issue. It turned out that I was adding a prototype method to the class "Object" that already exist.