nca
nca

Reputation: 445

React npm start issue

I get this error when do npm start. I tried deleting node modules and doing npm install again but dint fix issue

  1. ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./main.js
  2. Module not found: Error: Can't resolve 'babel' in '*****'

  3. @ multi (webpack)-dev-server/client?http://localhost:8080 ./main.js

  4. webpack: Failed to compile

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

This is my package.json
    {
      "name": "proj3",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "webpack-dev-server"
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "react": "^15.6.1",
        "react-dom": "^15.6.1"
      },
      "devDependencies": {
        "webpack": "^3.4.1",
        "webpack-dev-server": "^2.6.1"
      }
    }

Upvotes: 0

Views: 129

Answers (1)

hendrixchord
hendrixchord

Reputation: 5434

you need to add Babel package to your project since it transpiles ES6 code (react).

This are the packages.

babel-loader
babel-core
babel-preset-es2015
babel-preset-react

Upvotes: 1

Related Questions