New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'webpack/lib/node/NodeTemplatePlugin' using cli 1.1.1 #6641

Closed
ivalexa opened this Issue Jun 10, 2017 · 18 comments

Comments

Projects
None yet
@ivalexa

ivalexa commented Jun 10, 2017

OS?

@angular/cli: 1.1.1
node: 8.0.0
os: win32 x64 (Windows 10)
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.1.1
@angular/compiler-cli: 4.1.3

Repro steps:

  1. Install node 8 & @angular/cli: 1.1.1
  2. ng new demo
  3. npm start

Failure message:

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. (C:\ng413\demo\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. (C:\ng413\demo\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)

@Markus-Ende

This comment has been minimized.

Show comment
Hide comment
@Markus-Ende

Markus-Ende Jun 12, 2017

Had the same problem, but it turned out that I just forgot to delete the new package-lock file introduced with npm 5. Just deleted this and the node_modules and everything worked as expected after npm install.

Markus-Ende commented Jun 12, 2017

Had the same problem, but it turned out that I just forgot to delete the new package-lock file introduced with npm 5. Just deleted this and the node_modules and everything worked as expected after npm install.

@ivalexa ivalexa closed this Jun 12, 2017

@thefill

This comment has been minimized.

Show comment
Hide comment
@thefill

thefill Jun 17, 2017

@Markus-Ende solution worked for me. Thx!

thefill commented Jun 17, 2017

@Markus-Ende solution worked for me. Thx!

@toddwseattle

This comment has been minimized.

Show comment
Hide comment
@toddwseattle

toddwseattle Jun 17, 2017

this worked for me as well. might be nice to see a note in the 'upgrading section'.

toddwseattle commented Jun 17, 2017

this worked for me as well. might be nice to see a note in the 'upgrading section'.

@MoxxNull

This comment has been minimized.

Show comment
Hide comment
@MoxxNull

MoxxNull Jun 26, 2017

@Markus-Ende That did the trick, thank you!

MoxxNull commented Jun 26, 2017

@Markus-Ende That did the trick, thank you!

@treeder

This comment has been minimized.

Show comment
Hide comment
@treeder

treeder Jun 30, 2017

Could someone explain why we need to delete the lock file?

treeder commented Jun 30, 2017

Could someone explain why we need to delete the lock file?

@jkyoutsey

This comment has been minimized.

Show comment
Hide comment
@jkyoutsey

jkyoutsey Jul 6, 2017

I've deleted my lock file and I still get the error. Every time you do an npm install it's going to add the lock file back.

jkyoutsey commented Jul 6, 2017

I've deleted my lock file and I still get the error. Every time you do an npm install it's going to add the lock file back.

@klaascuvelier

This comment has been minimized.

Show comment
Hide comment
@klaascuvelier

klaascuvelier Jul 11, 2017

I have this same issue with angular-cli@1.2.0, but only on our test server, not locally.

I'm not a fan of removing the package-lock file.
Adding webpack as dev-dependency worked for m (got the idea here webpack/webpack#2060). It's not optimal either, but it seems okay is a temporary fix.

klaascuvelier commented Jul 11, 2017

I have this same issue with angular-cli@1.2.0, but only on our test server, not locally.

I'm not a fan of removing the package-lock file.
Adding webpack as dev-dependency worked for m (got the idea here webpack/webpack#2060). It's not optimal either, but it seems okay is a temporary fix.

@piernik

This comment has been minimized.

Show comment
Hide comment
@piernik

piernik Jul 27, 2017

Had the same problem - installing npm i webpack --save-dev sloved it

piernik commented Jul 27, 2017

Had the same problem - installing npm i webpack --save-dev sloved it

@nulllpointer

This comment has been minimized.

Show comment
Hide comment
@nulllpointer

nulllpointer Oct 7, 2017

Thanks, this solved the issue!!!!

nulllpointer commented Oct 7, 2017

Thanks, this solved the issue!!!!

@Markus-Ende

This comment has been minimized.

Show comment
Hide comment
@Markus-Ende

Markus-Ende Oct 9, 2017

@treeder the package-lock prevented a new webpack version to be installed (it's like the former npm-shrinkwrap). The version defined in the package-lock file beats the version defined in package.json, so npm i just reinstalled the old webpack files. Deleting the package-lock and then running npm i creates a whole new package-lock file with the latest package versions according to package.json. If you just want to refresh webpack, you can just directly install it via npm i webpack --save-devas @piernik said. Directly installing a package always refreshs the package-lock.

For further documentation about the package-lock see the npm lockfiles documentation on docs.npmjs.com

Markus-Ende commented Oct 9, 2017

@treeder the package-lock prevented a new webpack version to be installed (it's like the former npm-shrinkwrap). The version defined in the package-lock file beats the version defined in package.json, so npm i just reinstalled the old webpack files. Deleting the package-lock and then running npm i creates a whole new package-lock file with the latest package versions according to package.json. If you just want to refresh webpack, you can just directly install it via npm i webpack --save-devas @piernik said. Directly installing a package always refreshs the package-lock.

For further documentation about the package-lock see the npm lockfiles documentation on docs.npmjs.com

@goeranhomberg

This comment has been minimized.

Show comment
Hide comment
@goeranhomberg

goeranhomberg Nov 12, 2017

npm i webpack --save-dev

worked for me. Thx for the hint 👍

goeranhomberg commented Nov 12, 2017

npm i webpack --save-dev

worked for me. Thx for the hint 👍

@danijose danijose referenced this issue Nov 14, 2017

Closed

ng seve #167

@dev-niiaddy

This comment has been minimized.

Show comment
Hide comment
@dev-niiaddy

dev-niiaddy Jan 27, 2018

@Markus-Ende thank you. You saved my life... I almost went nuts

dev-niiaddy commented Jan 27, 2018

@Markus-Ende thank you. You saved my life... I almost went nuts

@Feyrr007

This comment has been minimized.

Show comment
Hide comment
@Feyrr007

Feyrr007 Feb 20, 2018

npm i webpack --save-dev
Workded for me too. Thanks so much!

Feyrr007 commented Feb 20, 2018

npm i webpack --save-dev
Workded for me too. Thanks so much!

@MateuszKita

This comment has been minimized.

Show comment
Hide comment
@MateuszKita

MateuszKita Mar 31, 2018

If somebody will have next issue - "Cannot read property 'thisCompilation' of undefined" after
npm i webpack --save-dev or deleting package-lock.json and reinstalling node_modules
please try

npm remove webpack
npm install webpack@3.11.0

MateuszKita commented Mar 31, 2018

If somebody will have next issue - "Cannot read property 'thisCompilation' of undefined" after
npm i webpack --save-dev or deleting package-lock.json and reinstalling node_modules
please try

npm remove webpack
npm install webpack@3.11.0
@SerkanSipahi

This comment has been minimized.

Show comment
Hide comment
@SerkanSipahi

SerkanSipahi May 25, 2018

after removing the package-lock.json it worked for me, thank you :)

SerkanSipahi commented May 25, 2018

after removing the package-lock.json it worked for me, thank you :)

@satvik1986

This comment has been minimized.

Show comment
Hide comment
@satvik1986

satvik1986 Jul 25, 2018

Angular Live Development Server is listening on localhost:4300, open your browser on http://localhost:4300/ **
65% building modules 466/507 modules 41 active …modules\core-js\modules_string-html.js× 「wdm」: Error: No module factory available for dependency type: ContextElementDependency
at addDependency (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:407:12)
at iterationOfArrayCallback (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:88:3)
at addDependenciesBlock (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:423:5)
at iterationOfArrayCallback (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:88:3)
at addDependenciesBlock (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:426:5)
at Compilation.processModuleDependencies (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:434:4)
at afterBuild (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:556:15)
at buildModule.err (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:600:11)
at callback (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:358:35)
at module.build.error (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:394:12)
at resolveDependencies (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\ContextModule.js:233:4)
at ContextModule.result.resolveDependencies (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:476:25)
at ContextModule.build (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\ContextModule.js:158:8)
at Compilation.buildModule (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:362:10)
at factory.create (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:583:14)
at hooks.afterResolve.callAsync (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\ContextModuleFactory.js:150:16)
D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules\neo-async\async.js:14
throw new Error('Callback was already called.');
^

Error: Callback was already called.
at throwError (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules\neo-async\async.js:14:11)
at D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules\neo-async\async.js:2805:7
at process._tickCallback (internal/process/next_tick.js:61:11)

satvik1986 commented Jul 25, 2018

Angular Live Development Server is listening on localhost:4300, open your browser on http://localhost:4300/ **
65% building modules 466/507 modules 41 active …modules\core-js\modules_string-html.js× 「wdm」: Error: No module factory available for dependency type: ContextElementDependency
at addDependency (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:407:12)
at iterationOfArrayCallback (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:88:3)
at addDependenciesBlock (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:423:5)
at iterationOfArrayCallback (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:88:3)
at addDependenciesBlock (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:426:5)
at Compilation.processModuleDependencies (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:434:4)
at afterBuild (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:556:15)
at buildModule.err (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:600:11)
at callback (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:358:35)
at module.build.error (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:394:12)
at resolveDependencies (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\ContextModule.js:233:4)
at ContextModule.result.resolveDependencies (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:476:25)
at ContextModule.build (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\ContextModule.js:158:8)
at Compilation.buildModule (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:362:10)
at factory.create (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\Compilation.js:583:14)
at hooks.afterResolve.callAsync (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules@angular-devkit\build-angular\node_modules\webpack\lib\ContextModuleFactory.js:150:16)
D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules\neo-async\async.js:14
throw new Error('Callback was already called.');
^

Error: Callback was already called.
at throwError (D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules\neo-async\async.js:14:11)
at D:\Working\JainConnection\Dev\JainConnectionWebSite\node_modules\neo-async\async.js:2805:7
at process._tickCallback (internal/process/next_tick.js:61:11)

@HuangHongRui

This comment has been minimized.

Show comment
Hide comment
@HuangHongRui

HuangHongRui Aug 11, 2018

npm i webpack --save-dev
worked for me. 3Q 👍

HuangHongRui commented Aug 11, 2018

npm i webpack --save-dev
worked for me. 3Q 👍

@MsaadAl

This comment has been minimized.

Show comment
Hide comment
@MsaadAl

MsaadAl Sep 25, 2018

The error you're all facing is only because webpack version, the latest update v4 has a lot of issue, the solution you need is just reinstall webpack again with 3.12.0 and it will work. This version cause a lot of error, and this is the solution I solve the error with. and it works now perfect. I hope that help

MsaadAl commented Sep 25, 2018

The error you're all facing is only because webpack version, the latest update v4 has a lot of issue, the solution you need is just reinstall webpack again with 3.12.0 and it will work. This version cause a lot of error, and this is the solution I solve the error with. and it works now perfect. I hope that help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment