webpack打包报错:Error: Cannot find module ‘webpack/lib/node/NodeTemplatePlugin‘

webpack打包报错:
[webpack-cli] Error: Cannot find module ‘webpack/lib/node/NodeTemplatePlugin’

错误提示:

[webpack-cli] Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Require stack:
- E:\Astudy\Athree\03_Webpack\mydemo\demo4\node_modules\[email protected]@html-webpack-plugin\lib\child-compiler.js
- E:\Astudy\Athree\03_Webpack\mydemo\demo4\node_modules\[email protected]@html-webpack-plugin\lib\cached-child-compiler.js        
- E:\Astudy\Athree\03_Webpack\mydemo\demo4\node_modules\[email protected]@html-webpack-plugin\index.js
- E:\Astudy\Athree\03_Webpack\mydemo\demo4\webpack.config.js
- E:\nodejs\node_global\node_modules\webpack-cli\lib\webpack-cli.js
- E:\nodejs\node_global\node_modules\webpack-cli\lib\bootstrap.js
- E:\nodejs\node_global\node_modules\webpack-cli\bin\cli.js
- E:\nodejs\node_global\node_modules\webpack\bin\webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (E:\nodejs\node_global\node_modules\webpack-cli\node_modules\[email protected]@v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (E:\Astudy\Athree\03_Webpack\mydemo\demo4\node_modules\[email protected]@html-webpack-plugin\lib\child-compiler.js:14:28)
    at Module._compile (E:\nodejs\node_global\node_modules\webpack-cli\node_modules\[email protected]@v8-compile-cache\v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'E:\\Astudy\\Athree\\03_Webpack\\mydemo\\demo4\\node_modules\\[email protected]@html-webpack-plugin\\lib\\child-compiler.js', 
r.js',
    'E:\\Astudy\\Athree\\03_Webpack\\mydemo\\demo4\\webpack.config.js',
    'E:\\nodejs\\node_global\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
    'E:\\nodejs\\node_global\\node_modules\\webpack-cli\\lib\\bootstrap.js',
    'E:\\nodejs\\node_global\\node_modules\\webpack-cli\\bin\\cli.js',
    'E:\\nodejs\\node_global\\node_modules\\webpack\\bin\\webpack.js'
  ]
}

解决办法:

执行命令 npm link webpack --save-dev

然后再执行webpack就可以了

你可能感兴趣的:(前端技术分享,vue,webpack)