Angular-cli: Cannot find module 'webpack' after moving from @latest to @next

Created on 7 Jun 2018  路  7Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report 

Area

- [x] devkit

Versions

nodejs10.4.0
npm6.1.0
Angular CLI: 6.1.0-beta.2
Node: 10.4.0
OS: win32 x64
Angular: 6.1.0-beta.0
... common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.7.0-beta.2 (cli-only)
@angular-devkit/build-angular   0.7.0-beta.2
@angular-devkit/build-webpack   0.7.0-beta.2
@angular-devkit/core            0.7.0-beta.2 (cli-only)
@angular-devkit/schematics      0.7.0-beta.2 (cli-only)
@angular/cdk                    6.2.1
@angular/cli                    6.1.0-beta.2
@angular/material               6.2.1
@schematics/angular             0.7.0-beta.2 (cli-only)
@schematics/update              0.7.0-beta.2 (cli-only)
rxjs                            6.2.0
typescript                      2.7.2

Repro steps

I was in cli 6 and want try ng update --next --all it cancel me cause of peer dependances
ng update --next --all --force success but get me last version of typescrip, I need manually in package.json write ~2.7.2 then npm install

After that I run ng serve and I get :

Cannot find module 'webpack'
Error: Cannot find module 'webpack'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\...\node_modules\@angular-devkit\build-webpack\src\webpack\index.js:6:17)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)

Then I remove node_modules manually then rerun npm install -> same error output.

Desired functionality

First of all avoid always update typescript to last version keep only supported version. Then I desire to update easily.

Mention any other details that might be useful

Actually I can't quit this @next and come back to @latest I need fix my package.json manually. Damn!

cc @filipesilva

etmisc regression bufix

Most helpful comment

I had to delete package-lock.json, then remove and reinstall node_modules.

All 7 comments

I think that was some badly configured peer dependencies on our side. https://github.com/angular/angular-cli/pull/11152 should fix it.

Getting you the latest TypeScript was fixed by https://github.com/angular/devkit/pull/987

I think everything here is now fixed.

Try this...

npm uninstall --save webpack
npm install --save-dev webpack

don't try it, we don't have to install webpack it will break if you will execute

rm -rf node_modules
npm install
ng serve

I had to delete package-lock.json, then remove and reinstall node_modules.

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._

Was this page helpful?
0 / 5 - 0 ratings