0

npm start 时出现此错误。我尝试删除节点模块并再次执行 npm install 但修复了问题

  1. 多(webpack)-dev-server/client 中的错误?http://localhost:8080 ./main.js
  2. 找不到模块:错误:无法解析 '*****' 中的 'babel'

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

  4. webpack:编译失败

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"
      }
    }
4

1 回答 1

1

您需要将 Babel 包添加到您的项目中,因为它会转译 ES6 代码(反应)。

这是包裹。

babel-loader
babel-core
babel-preset-es2015
babel-preset-react
于 2017-08-04T06:49:54.483 回答