Задать вопрос
@nikita_lea

HTMLWebpackPlugin ошибка при установке плагина, не может найти модуль html-webpack-plugin\lib\loader.js, как решить проблему?

Я дико извиняюсь за возможно глупый вопрос, но не могу решить данную проблему. Начал осваивать webpack, устанавливаю первый плагин и сразу выскакивает такая ошибка:
если я правильно понимаю в чем ошибка, то вебпак не может найти модуль "Cannot find module" в .....\lib\loader.js
, но он есть в этой папке.

моя конфигурация:

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: [
new HTMLWebpackPlugin({
template: path.resolve(__dirname, './src/index.html'),
}),

],
}

код с консоли:

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>
  • Вопрос задан
  • 697 просмотров
Подписаться 1 Средний Комментировать
Пригласить эксперта
Ответы на вопрос 1
@YahorDanchanka
Frontend developer
Удалите папку node_modules и установите пакеты заново.
npm i webpack webpack-cli html-webpack-plugin -D
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы