I have error after upgrading angular-cli from 1.6.0-rc1 to 1.6.0-rc2.
Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Angular CLI: 1.6.0-rc.2
Node: 8.8.1
OS: win32 x64
Angular: 5.1.0-rc.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-webworker, router
... service-worker
@angular/cdk: 5.0.0-rc.2
@angular/cli: 1.6.0-rc.2
@angular/material-moment-adapter: 5.0.0-rc.2
@angular/material: 5.0.0-rc.2
@angular/platform-webworker-dynamic: 5.0.5
@angular-devkit/build-optimizer: 0.0.34
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.39
@ngtools/json-schema: 1.1.0
@schematics/angular: 0.1.9
typescript: 2.6.2
webpack: error
I also have the issue with version Angular CLI 1.5.4, on project installed yesterday.
I do believe the warning is not related to the error, as I have the warning for a long time and the error is new.
$ ng serve
Your global Angular CLI version (1.5.4) is greater than your local
version (1.2.6). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\legrosj\Documents\_Rebond\workspace\rebond\rebond-front\node_modules\html-webpack-plugin\lib\compiler.js:11:26)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\legrosj\Documents\_Rebond\workspace\rebond\rebond-front\node_modules\html-webpack-plugin\index.js:7:21)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
OS: win 10
node v8.9.1
Angular 5.0.3
So you are getting webpack error.
Try this -
That should solve the problem.
That error generally indicates the presence of multiple versions of webpack. The instructions provided by @lazyspark should sort out the problem with the additional step of ensuring that webpack is not present within the project's package.json before npm installing. If the problem still persists please re-open the issue.
@lazyspark can you please share where the file package-lock.json is located. I searched my project and found few in node_modules.
@naveedahmed1 it is the package-lock.json in base/root folder of the project along with package.json. It wont be created if you have never run npm install.
I got this same error, reinstalled it locally and ran it with package scripts and it worked. Not sure why.
Note: fix from https://github.com/webpack/webpack/issues/2131
npm remove webpack -g
npm i webpack --save-dev
If "@angular/cli": "^1.5.0" is defined in package.json and 1.5.0 is currently installed in node_modules everything works fine.
As soon as I delete the local node_modules folder and use npm install the currently available CLI minor version will be installed (now: 1.6.5), but not all necessary sub dependencies get installed. E.g. webpack is not installed or not correctly installed. ng -v shows an error for webpack and you can see that several dependencies normally listed below Angular CLI are missing.
If I directly define "@angular/cli": "^1.6.5" and use npm install everything works fine.
@mikezks This worked perfectly. Thanks. :)
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
So you are getting webpack error.
Try this -
That should solve the problem.