webpack打包时错误Cannot find module 'webpack/lib/node/NodeTemplatePlugin'

错误提示

Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object. (E:\reacthome\webpack\chapter1\node_modules\html-webpack-plugin\lib\compiler.js:9:28)
    at Module._compile (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)

解决办法

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

PS E:\reacthome\webpack\chapter1> npm link webpack --save-dev
E:\reacthome\webpack\chapter1\node_modules\webpack -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack

然后在执行webpack就可以了

你可能感兴趣的:(前端)