reactjswebpackbabeljs

Blank white screen React & Webpack / Babel has been moved to babel-core


I'm working through a React tutorial and am getting a blank white screen during setup. I only get a blank white screen when I run npm start but I can see the blank div when I inspect the element.

I found a similar issue here but the solution doesn't work for me

I get 1 error: The node API for babel has been moved to babel-core. @ multi main

I've copied all of the exact files from the github files and this is still what I'm getting.

I've already tried npm uninstall babel -g but it still gives the same error and white screen.

Here is my webpack.config.js

module.exports = {
  entry: './main.js',
  output: {
    path: './',
    filename: 'index.js'
  },
  devServer: {
    inline: true,
    port: 3333
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react']
        }
      }
    ]
  }
}

Here is my package.json

    {
    "name": "es6-react-setup",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
        "start": "webpack-dev-server"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
        "babel-core": "^6.2.1",
        "babel-loader": "^6.2.0",
        "babel-preset-es2015": "^6.1.18",
        "babel-preset-react": "^6.1.18",
        "react": "^0.14.3",
        "react-dom": "^0.14.3"
    },
    "description": "Setup files for React in ES6 lessons"
}

Solution

  • I tried deleting node_modules and reinstalling all dependencies a second time and it worked for me.

    I think this is a duplicate of this post now: Using webpack with babel and babel-preset-react and babel-preset-es2015