Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用网页包配置创建react应用程序时出现无效配置错误_Reactjs_Webpack - Fatal编程技术网

Reactjs 使用网页包配置创建react应用程序时出现无效配置错误

Reactjs 使用网页包配置创建react应用程序时出现无效配置错误,reactjs,webpack,Reactjs,Webpack,无法使用react配置网页包 以下是错误: 无效的配置对象。已使用与API架构不匹配的配置对象初始化Web包。 -配置。条目['main']不应包含项目'-'两次。 ->非空字符串的非空数组 我已配置Web包并尝试 下面是webpack.config.js const path = require('path'); const HWP = require('html-webpack-plugin'); module.exports = { entry: path.join(__dir

无法使用react配置网页包

以下是错误:

无效的配置对象。已使用与API架构不匹配的配置对象初始化Web包。
-配置。条目['main']不应包含项目'-'两次。 ->非空字符串的非空数组

我已配置Web包并尝试

下面是webpack.config.js

 const path = require('path');
 const HWP = require('html-webpack-plugin');
 module.exports = {
   entry: path.join(__dirname, '/src/index.js'),
    output: {
    filename: 'build.js',
    path: path.join(__dirname, '/dist')},
module:{
   rules:[{
       test: /\.js$/,
      exclude: /node_modules/,
       loader: 'babel-loader'
    }]
  },
  plugins:[
    new HWP(
       {template: path.join(__dirname,'/src/index.html')}
   )
  ]
}

我想这会管用的

 const path = require('path');
 const HWP = require('html-webpack-plugin');
 module.exports = {
   entry: ['./src/index.js'],
    output: {
    filename: 'build.js',
    path: path.join(__dirname, 'dist')},
module:{
   rules:[{
       test: /\.js$/,
      exclude: /node_modules/,
       loader: 'babel-loader'
    }]
  },
  plugins:[
    new HWP(
       {template: path.join(__dirname,'src/index.html')}
   )
  ]
}

更改package.json中的scripts start命令(如下所示)使其正常工作

"start": "webpack-dev-server --config webpack.config.js --port 3000",

只需使用CreateReact应用程序并保存您自己配置的网页包。我知道CreateReact应用程序。我正试图在网页上了解更多信息。您在哪行代码中出错?我认为条目需要是数组或对象。请尝试
entry:{main:path.join(uu dirname,'/src/index.js')},
configuration.entry['main']不应包含项'-'两次。同一问题。-->配置对象无效。已使用与API架构不匹配的配置对象初始化Web包。-配置。条目['main']不应包含项目'-'两次。