angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open alvipeo opened this issue 9 years ago • 21 comments

After upgrading to 1.4.5 (Windows 10, Node 8.6.0) and running ng serve I get this error:

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

I rebooted my machine, reinstalled all npm packages, nothing helps.

Basically, this is a blocking issue.

alvipeo avatar Oct 07 '17 16:10 alvipeo

Same problem here... ( but MacOS ).

"dependencies": {

"@angular/animations": "^4.4.4",
"@angular/cdk": "^2.0.0-beta.12",
"@angular/common": "^4.4.4",
"@angular/compiler": "^4.4.4",
"@angular/core": "^4.4.4",
"@angular/flex-layout": "^2.0.0-beta.9",
"@angular/forms": "^4.4.4",
"@angular/http": "^4.4.4",
"@angular/material": "^2.0.0-beta.12",
"@angular/platform-browser": "^4.4.4",
"@angular/platform-browser-dynamic": "^4.4.4",
"@angular/router": "^4.4.4",
"ack-angular-webcam": "^1.3.12",
"core-js": "^2.4.1",
"material-design-icons": "^3.0.1",
"roboto-fontface": "^0.8.0",
"rxjs": "^5.4.2",
"zone.js": "^0.8.18"

},

"devDependencies": {

"@angular/cli": "^1.4.5",
"@angular/compiler-cli": "^4.4.4",
"@angular/language-service": "^4.4.4",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.89",
"codelyzer": "~3.1.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "^5.7.0",
"typescript": "~2.3.3"

}

npm i npm WARN [email protected] requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of webpack@1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of webpack@^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of webpack@^2.0.0 || >= 3.0.0-rc.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of webpack@^1.9 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

I also deleted the node_modules folder and ran npm i again. I'm build a web.app using angular-cli, angular material and angular flexlayout.

goeranhomberg avatar Oct 08 '17 12:10 goeranhomberg

ok, I downgraded NPM to 5.3.0, reinstall CLI and now everything works.

alvipeo avatar Oct 08 '17 20:10 alvipeo

Finally I got it. It was not angular Cli itself. I had to clear the browsercache the hard way... and hat to recognize the delta between the latest angular material 2 release ( Beta 12 ) and the docs... :(

goeranhomberg avatar Oct 09 '17 19:10 goeranhomberg

@goeranhomberg , not sure I understand your solution. are you still on 1.4.5?

alvipeo avatar Oct 09 '17 21:10 alvipeo

@alvipeo yep... I figured out that updating Angular CLI and Angular Material 2 at the same time can mix up some things and lead you to some missunderstandings.

My solution for both was to follow the CLI update instructions ( including npm cache clean --force ) and deleting my browsers cache. After this I completely removed all components containing angular material 2 stuff and my app was alive again. To round things up I had to find out that the angular material 2 docs are not up to date with some braking changes they made. After going through these pitfalls everything's good again (see Material2 Issue ).

goeranhomberg avatar Oct 10 '17 06:10 goeranhomberg

I had the same issue but on our CI. I downgraded the CLI from 1.4.5 to 1.4.4 and that fixed my issue

mehrad-rafigh avatar Oct 10 '17 08:10 mehrad-rafigh

@goeranhomberg I don't even have Material in my project. so you have something else. And I did cache clean too, that didn't help. Just downgrading NPM helped.

alvipeo avatar Oct 10 '17 08:10 alvipeo

Hi @alvipeo,

This is a problem with NPM. Which NPM version are you using?

You're missing webpack in your node_modules folder. No idea why without further investigation, but I cannot reproduce on my computer.

hansl avatar Oct 12 '17 00:10 hansl

it was npm 5.4.1. Haven't tried 5.4.2 yet. Will try today

alvipeo avatar Oct 12 '17 09:10 alvipeo

Same problem here, I was in 5.4.2 and downgrade NPM to 5.3.0 and didn't help. My application is almost completely built with Material 2 and I can not remove the components. I'm very lost at this moment.

NellyDesu avatar Oct 12 '17 15:10 NellyDesu

hi guys, maybe try deleting node_modules & package-lock.json files. at least i solve the problem.

cipchk avatar Oct 13 '17 02:10 cipchk

For me this solved the problem after deleting node_modules and installing again with nmp install

npm remove webpack -g npm i webpack --save-dev npm run webpack

NellyDesu avatar Oct 13 '17 18:10 NellyDesu

For me, the problem was the webpack globally installed. When I deleted it, a-cli worked. I think that a-cli was looking for some files globally which they weren't installed.

Geoide avatar Oct 18 '17 06:10 Geoide

same think happened to me today when I tried to upgrade from 1.4.7=>1.4.8

node_modules/webpack/* is missing after this upgrade and warning like this appears:

npm WARN @ngtools/[email protected] requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

I have MacOS and [email protected]

rokerkony avatar Oct 19 '17 10:10 rokerkony

I also just had this issue after upgrading angular-cli from 1.4.4 to 1.4.8 and angular (and related libraries) from 4.4.4 to 4.4.6 and also upgrading npm from 5.4.2 to 5.5.1.

This proved to be the gazillionth time that this relatively newly introduced package-lock.json is screwing things up for me. I deleted this file and the node_modules folder, ran npm install and everything works now without any downgrades or version changes.

radoslavpetranov avatar Oct 19 '17 22:10 radoslavpetranov

after doing :

remove node_modules
remove package-lock.json
npm cache clean -f

works again for me!

elvisbegovic avatar Oct 20 '17 11:10 elvisbegovic

having the same problem Cannot find module 'webpack/lib/node/NodeTemplatePlugin' For me last working version of @angular/cli was 1.5.0-rc.2 RC3 -> RC8 doesn't work. npm --version: 5.5.1 node modules are installed correctly.

update: Install webpack as a devDependency. Fixed for me.

GeorgeKnap avatar Oct 31 '17 07:10 GeorgeKnap

Have the same problem, on macOS 10.12.6.

NG Cli: 1.5.0, Node 8.9.0 (LTS), NPM 5.5.1

Have used CLI 1.4.9 for weeks without a problem.

Created a new project with CLI 1.5.0, carried over all changes in packages.json, .angular-cli.json, src/polyfills.ts to the project which initially was created with CLI 1.4.0 I believe. Have upgraded it gradually up to 1.4.9, it has worked nicely.

@istiti has given a valuable advise, it has worked for me.

catull avatar Nov 02 '17 10:11 catull

@istiti thanks!

removing node_modules and package-lock.json then reinstalling fixed things.

victormejia avatar Nov 03 '17 21:11 victormejia

I just came here having the same problem and I solved as @istiti said.

rtalexk avatar Nov 08 '17 02:11 rtalexk