Answer the question
In order to leave comments, you need to log in
HTMLWebpackPlugin plugin installation error, cannot find html-webpack-plugin\lib\loader.js module, how to solve the problem?
I'm wildly sorry for a possibly stupid question, but I can not solve this problem. I started to master webpack, I installed the first plugin and immediately the following error pops up:
if I understand correctly what the error is, then webpack cannot find the "Cannot find module" module in .....\lib\loader.js
, but it is in this folder.
my config:
const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path .resolve(__dirname, 'dist')
},
plugins:
template: path.resolve(__dirname, './src/index.html'),
}),
],
}
console code:
PS C:\Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset> webpack
asset index.html 11.7 KiB [emitted]
asset bundle.js 5.1 KiB [compared for emit] (name: main)
runtime modules 670 bytes 3 modules
cacheable modules 437 bytes
../../../../#new start /for_study/webpack/WEBPACKset/src/index.js 122 bytes [built] [code generated]
../../../../#new start/for_study/webpack/WEBPACKset/src/Post.js 315 bytes [built] [code generated]
ERROR in Error: Child compilation failed:
Module build failed (from ../../../../#new start/for_study/webpack/WEBPACKset/node_modules/html-webpack-plugin/lib/loader.js):
Error: Cannot find module 'C: \Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset\node_modules\html-webpack-plugin\lib\loader.js'
Require stack:
- C:\Users\Nikita\Desktop\#new start\for_study\ webpack\WEBPACKset\node_modules\loader-runner\lib\loadLoader.js
- C:\Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset\node_modules\loader-runner\lib\LoaderRunner.js
- C:\ Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset\node_modules\webpack\lib\NormalModule.js
.
.
.
ModuleBuildError: Module build failed (from ../../../../#new start/for_study/webpack/WEBPACKset/node_modules/html-webpack-plugin/lib/loader.js):
Error: Cannot find module ' C:\Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset\node_modules\html-webpack-plugin\lib\loader.js'
Require stack:
- C:\Users\Nikita\Desktop\#new start\ for_study\webpack\WEBPACKset\node_modules\loader-runner\lib\loadLoader.js
- C:\Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset\node_modules\loader-runner\lib\LoaderRunner.js
.
.
.
[WEBPACKset]/[webpack]/lib/Compilation.js:1321:12
- ModuleBuildError: Module build failed (from ../../../../#new start/for_study/webpack/WEBPACKset/node_modules/html-webpack-plugin/lib/loader.js):
- Error: Cannot find module 'C:\Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset\node_modules\html-webpack-plugin\lib\loader.js'
- Require stack:
- - C:\Users\Nikita\Desktop\ #new start\for_study\webpack\WEBPACKset\node_modules\loader-runner\lib\loadLoader.js
- - C:\Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset\node_modules\loader-runner\lib\ LoaderRunner.js
_
.
.
- loader.js:880 Function.Module._resolveFilename
internal/modules/cjs/loader.js:880:15
- loader.js:725 Function.Module._load
internal/modules/cjs/loader.js:725:27
- loader.js:952 Module.require
internal/modules/cjs/loader.js:952:19
- v8-compile-cache.js:159 require
[WEBPACKset]/ [v8-compile-cache]/v8-compile-cache.js:159:20
- loadLoader.js:19 loadLoader
[WEBPACKset]/[loader-runner]/lib/loadLoader.js:19:17
- LoaderRunner.js: 182 iteratePitchingLoaders
[WEBPACKset]/[loader-runner]/lib/LoaderRunner.js:182:2
- LoaderRunner.js:397 runLoaders
[WEBPACKset]/[loader-runner]/lib/LoaderRunner.js:397:2
- NormalModule. js:756 NormalModule.doBuild
[WEBPACKset]/[webpack]/lib/NormalModule.js:756:3
- NormalModule.js:910 NormalModule.build
[WEBPACKset]/[webpack]/lib/NormalModule.js:910:15
- Compilation.js:1321
[WEBPACKset]/[webpack]/lib/Compilation.js:1321:12
- NormalModule.js:703 processResult
[WEBPACKset] /[webpack]/lib/NormalModule.js:703:19
- NormalModule.js:809
[WEBPACKset]/[webpack]/lib/NormalModule.js:809:5
- LoaderRunner.js:399
[WEBPACKset]/[loader- runner]/lib/LoaderRunner.js:399:11
- LoaderRunner.js:185
[WEBPACKset]/[loader-runner]/lib/LoaderRunner.js:185:11
- loadLoader.js:33 loadLoader
[WEBPACKset]/[loader -runner]/lib/loadLoader.js:33:11
- LoaderRunner.js:182 iteratePitchingLoaders
[WEBPACKset]/[loader-runner]/lib/LoaderRunner.js:182:2
- LoaderRunner.js:397 runLoaders
[WEBPACKset]/[loader-runner]/lib/LoaderRunner.js:397:2
- NormalModule.js:756 NormalModule.doBuild
[WEBPACKset]/[webpack]/lib/NormalModule.js:756 :3
- NormalModule.js:910 NormalModule.build
[WEBPACKset]/[webpack]/lib/NormalModule.js:910:15
- Compilation.js:1321
[WEBPACKset]/[webpack]/lib/Compilation.js:1321: 12
- child-compiler.js:169
[WEBPACKset]/[html-webpack-plugin]/lib/child-compiler.js:169:18
- Compiler.js:548
[WEBPACKset]/[webpack]/lib/Compiler. js:548:11
- Compiler.js:1118
[WEBPACKset]/[webpack]/lib/Compiler.js:1118:17
- Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
[WEBPACKset]/[tapable]/lib/Hook.js:18:14
1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack 5.46.0 compiled with 2 errors in 364 ms
PS C:\Users\Nikita\Desktop\#new start\for_study\webpack\WEBPACKset>
Answer the question
In order to leave comments, you need to log in
Delete the node_modules folder and reinstall the packages.
npm i webpack webpack-cli html-webpack-plugin -D
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question