Reputation: 11
I'm updating Angular 11 to 12, angular core is updated. After updating "@angular-builders/custom-webpack" from 11 to 12 I'm getting error on ng serve command:
An unhandled exception occurred: Cannot find module 'webpack'
(which should be added by angular-cli, as far as I understand):
In latest angular versions the webpack dependency is manager by the CLI and you shouldn’t have a webpack entry in your package.json at all.
I tried removing node_modules and cleaning cache, but still, the problem is there. I also see many people suggest removing package-lock.json, but having this first comment by kevlarr in another thread: https://stackoverflow.com/a/51868816/5841925 I'm not sure it's a good idea to remove lock file. Does anyone have an idea how to solve it?
Upvotes: 1
Views: 2787
Reputation: 11
@Alena, Is your @angular-builders/custom-webpack and @angular-devkit/build-angular the version 12? If not, upgrade to the latest version available . After that, try to install, or link, webpack 5 into your project. Maybe you need to change the webpack-config, if there is configuration.
As I needed change the webpack-config, I would recommend this one, see on:
https://webpack.js.org/blog/2020-10-10-webpack-5-release/
Upvotes: 1