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\_html-webpack-plugin@4.5.1@html-webpack-plugin\lib\child-compiler.js
- E:\Astudy\Athree\03_Webpack\mydemo\demo4\node_modules\_html-webpack-plugin@4.5.1@html-webpack-plugin\lib\cached-child-compiler.js        
- E:\Astudy\Athree\03_Webpack\mydemo\demo4\node_modules\_html-webpack-plugin@4.5.1@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\_v8-compile-cache@2.2.0@v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (E:\Astudy\Athree\03_Webpack\mydemo\demo4\node_modules\_html-webpack-plugin@4.5.1@html-webpack-plugin\lib\child-compiler.js:14:28)
    at Module._compile (E:\nodejs\node_global\node_modules\webpack-cli\node_modules\_v8-compile-cache@2.2.0@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\\_html-webpack-plugin@4.5.1@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就可以了

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值