question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ng build` fails with error `Cannot find module 'webpack/lib/node/NodeTemplatePlugin'` after updating to `v1.3.0`

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

λ ng -v
     
@angular/cli: 1.3.0
node: 8.1.2
os: win32 x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.3.0
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1                              

Repro steps.

ng build fails with error Cannot find module 'webpack/lib/node/NodeTemplatePlugin' after updating to v1.3.0.

   "devDependencies": {
-    "@angular/cli": "1.2.7",
+    "@angular/cli": "1.3.0",

The log given by the failure.

λ ng build

Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (<redacted>\node_modules\html-webpack-plugin\lib\compiler.js:11:26)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (<redacted>\node_modules\html-webpack-plugin\index.js:7:21)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)

Mention any other details that might be useful.

Might be related to #6641.

Installing webpack as a devDependency can be used as a workaround.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:22
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

125reactions
tapas4javacommented, Oct 19, 2017

I faced this issue many times recently and always the fix worked for me is :

rm -rf node_modules
rm package-lock.json
npm install
44reactions
Sayarencommented, Dec 26, 2017

rm -rf node_modules rm package-lock.json npm cache verify npm install

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng build fails with cannot find module error - Stack Overflow
I renamed all Interfaces and removed the leading I from the names and now the build process is working as expected.
Read more >
Cannot find module 'node-sass' on NPM build
node_modules/sass-loader/lib/loader.js): Error: Cannot find module ... I tried running a build 'ng build --prod' locally and didnt encounter any errors.
Read more >
Fixing Could not find module @angular-devkit/build-angular ...
To fix Could not find module angular-devkit-build-angular error in Angular follow the below steps 1. Delete node_modules folder and run npm ...
Read more >
Identify and Fix Build and Deployment Errors in Your Angular ...
This error occurs most commonly within your development environment (while running ng serve ) when you have created a new module on the ......
Read more >
How to fix error upgrading to Angular 13: unhandled exception ...
Home · Blog · How to fix error upgrading to Angular 13: unhandled exception occurred: Cannot find module 'webpack'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found