报错

ERROR in   Error: Child compilation failed:
  Module not found: Error: Can't resolve 'D:\练习\webpack\index.html' in 'D:\练习\webpack'
  ModuleNotFoundError: Module not found: Error: Can't resolve 'D:\练习\webpack\index.html' in 'D:\练习\webpack'
      at D:\练习\webpack\node_modules\webpack\lib\Compilation.js:2016:28
      at D:\练习\webpack\node_modules\webpack\lib\NormalModuleFactory.js:798:13
      at eval (eval at create (D:\练习\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:10:1)       
      at D:\练习\webpack\node_modules\webpack\lib\NormalModuleFactory.js:270:22
      at eval (eval at create (D:\练习\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)        
      at D:\练习\webpack\node_modules\webpack\lib\NormalModuleFactory.js:434:22
      at D:\练习\webpack\node_modules\webpack\lib\NormalModuleFactory.js:116:11
      at D:\练习\webpack\node_modules\webpack\lib\NormalModuleFactory.js:670:25
      at D:\练习\webpack\node_modules\webpack\lib\NormalModuleFactory.js:855:8
      at D:\练习\webpack\node_modules\webpack\lib\NormalModuleFactory.js:975:5


1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack 5.72.0 compiled with 2 errors in 167 ms

主要是因为index.html路径出问题导致的

const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {

    plugins:[

        new HtmlWebpackPlugin({

              template:"./index.html",

        })

    ]

}

把template里的路径改成src下的index 


const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {

    plugins:[

        new HtmlWebpackPlugin({

             template:"./scr/index.html",

        })

    ]

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐