Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin' Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin' node.js node.js

Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'


Update (Apr 2018)

Webpack 4 onwards you are required to install webpack-cli. You may also want to install webpack-dev-middleware if you need to use the options marked with a key on this page.

In this case the command to install is:

npm install --save-dev webpack webpack-cli html-webpack-plugin webpack-dev-server webpack-dev-middleware.

As mentioned above, webpack-dev-middleware should be optionally added based on your requirements.

Older answer

Node requires you to install webpack to your project.

You have 2 options to solve the above:

  1. Remove global webpack and install it locally

     npm install --save-dev html-webpack-plugin webpack webpack-dev-server```
  2. You can link the global webpack pkg to your project's node modules. The downside of this is that your project will be forced to use most updated webpack. This will create a problem only when some updates are not backwards compatible.

    npm i webpack -g; npm link webpack --save-dev

You can omit the html-webpack-plugin depending on your requirement.

You can find more info on this github issue page.



I faced a similar issue when updating my Angular app using ncu. Finally solved it by removing the node_modules and the package-lock.json and reinstall the packages.

You can run this in PowerShell (make sure you are in the correct working directory):

rm node_modules -r -forcerm package-lock.jsonnpm cache verifynpm install


I tried for hours almost every thing suggested on different threads on Stack overflow but nothing worked. Eventually (with a lot of luck) I tried this and it worked:

deleted node_modules library (not sure if required)npm install -g @angular/clinpm install @angular/clinpm install