1. ホーム
  2. node

エラーは正常に解決されました。モジュール 'html-webpack-plugin' が見つかりません。

2022-02-13 03:19:58
<パス

私のwebpack.config.js

var htmlwp = require('html-webpack-plugin');
module.exports={
    entry:'. /src/main.js', //specify the entry file for the package
    output:{
        path : __dirname+'/dist', // Note: __dirname is the absolute path to the directory where webpack.config.js is located
        filename:'build.js' // output file
    },
    plugins:[
        new htmlwp({
            title: 'home', //generated page title
Home page

            filename: 'index.html', //the name of the file generated in memory by webpack-dev-server, which automatically injects the build into the bottom of this page to enable the auto-refresh feature
            template: 'vue_02.html' //generated from the template index1.html (this file should be generated by the programmer himself)
        })
    })
}




パッケージング時に以下のエラーが発生します。

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run dev --scripts-prepend-node-path=auto

> @ dev /Users/lixinyu/myspace/xcEduUI01/xc-ui-pc-static-portal/webpacktest02
> webpack-dev-server --inline --hot --open --port 5008

module.js:557
    throw err;
    ^

Error: Cannot find module 'html-webpack-plugin'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/lixinyu/myspace/xcEduUI01/xc-ui-pc-static-portal/webpacktest02/webpack.config.js:1:76)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `webpack-dev-server --inline --hot --open --port 5008`
Exit status 1
npm ERR! 
Failed at the @ dev script. npm ERR!
This is probably not a problem with npm. There is likely additional logging output above.

A complete log of this run can be found in:
/Users/lixinyu/.npm/_logs/2019-05-11T07_45_49_325Z-debug.log

Process finished with exit code 1




webpack.config.jsがpdfからコピーされているため、フォントがおかしくなっているため、削除して再入力すると問題解決です