serve error after updating v11 to v12, compilation.errors.push(new webpack_1.WebpackError(message));
π Bug report
Command (mark with an x)
ng serve
- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
yes, version 11.2.12 runs correctly.
The error occurs when updating via the command
ng update @angular/core@12 @angular/cli@12
Description
A clear and concise description of the problem...after updating to @angular/core@12 @angular/cli@12 ng serve throws the following error
node_modules/@ngtools/webpack/src/webpack-diagnostics.js:17
compilation.errors.push(new webpack_1.WebpackError(message));
TypeError: webpack_1.WebpackError is not a constructor
which shuts down the
we are using "webpack": "^4.46.0" updating to webpack 5 (via ng update webpack) didn't help either.
π¬ Minimal Reproduction
In our case, updating angular 11 (11.2.13) to angular 12
π₯ Exception or Error
Compiler error, which stops the ng serve:
node_modules/@ngtools/webpack/src/webpack-diagnostics.js:17
compilation.errors.push(new webpack_1.WebpackError(message));
TypeError: webpack_1.WebpackError is not a constructor
TypeError: webpack_1.WebpackError is not a constructor
at Object.addError (/node_modules/@ngtools/webpack/src/webpack-diagnostics.js:17:29)
at /node_modules/@ngtools/webpack/src/ivy/diagnostics.js:19:39
at AngularWebpackPlugin.updateAotProgram (/node_modules/@ngtools/webpack/src/ivy/plugin.js:335:17)
at /node_modules/@ngtools/webpack/src/ivy/plugin.js:167:24
at Hook.eval [as call] (eval at create (/banax_angular/node_modules/@angular-devkit/build-angular/node_modules/tapable/lib/HookCodeFactory.js:19:10), :24:1)
at Hook.CALL_DELEGATE [as _call] (/node_modules/@angular-devkit/build-angular/node_modules/tapable/lib/Hook.js:14:14)
at Compiler.newCompilation (/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:1030:30)
at /node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:1073:29
at Hook.eval [as callAsync] (eval at create (/node_modules/@angular-devkit/build-angular/node_modules/tapable/lib/HookCodeFactory.js:33:10), :22:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/node_modules/@angular-devkit/build-angular/node_modules/tapable/lib/Hook.js:18:14)
at Compiler.compile (/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Compiler.js:1068:28)
at /node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Watching.js:134:19
at Hook.eval [as callAsync] (eval at create (/node_modules/@angular-devkit/build-angular/node_modules/tapable/lib/HookCodeFactory.js:33:10), :22:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/node_modules/@angular-devkit/build-angular/node_modules/tapable/lib/Hook.js:18:14)
at run (/node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Watching.js:88:33)
at /node_modules/@angular-devkit/build-angular/node_modules/webpack/lib/Watching.js:83:6
π Your Environment
Angular CLI: 12.0.0
Node: 16.1.0
Package Manager: npm 6.14.13
OS: darwin x64
Angular: 12.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1200.0
@angular-devkit/build-angular 12.0.0
@angular-devkit/core 12.0.0
@angular-devkit/schematics 12.0.0
@angular/cdk 11.2.12
@angular/flex-layout 11.0.0-beta.33
@angular/material 11.2.12
@schematics/angular 12.0.0
rxjs 6.6.7
typescript 4.2.4
webpack 4.46.0
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"optimization": false,
"sourceMap": true,
"namedChunks": true,
"extractLicenses": false,
"vendorChunk": false,
"buildOptimizer": false,
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.webmanifest",
"src/oanax-sw.js",
"src/offline.html"
],
"styles": [
"src/styles.scss",
"./node_modules/quill/dist/quill.core.css",
"./node_modules/quill/dist/quill.snow.css"
],
"scripts": ["./node_modules/quill/dist/quill.js"]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/@oanax/environments/environment.ts",
"with": "src/@oanax/environments/environment.prod.ts"
}
],
"outputHashing": "all",
"optimization": true,
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"serviceWorker": true,
"ngswConfigPath": "ngsw-config.json"
},
"ec": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
] },
"hmr": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"serviceWorker": true,
"ngswConfigPath": "ngsw-config.json",
"fileReplacements": [
{
"replace": "src/@oanax/environments/environment.ts",
"with": "src/@oanax/environments/environment.hmr.ts"
}
],
"optimization": true,
"outputHashing": "all",
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"local_api": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "src/@oanax/environments/environment.ts",
"with": "src/@oanax/environments/environment.local_api.ts"
}
]
},
"local_oanax": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "src/@oanax/environments/environment.ts",
"with": "src/@oanax/environments/environment.local_oanax.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
},
"hmr": {
"hmr": true,
"browserTarget": "app:build:hmr"
},
"ec": {
"browserTarget": "app:build:ec"
},
"local_api": {
"browserTarget": "app:build:local_api"
},
"local_oanax": {
"browserTarget": "app:build:local_oanax"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.scss",
"./node_modules/quill/dist/quill.core.css",
"./node_modules/quill/dist/quill.snow.css"
],
"scripts": ["./node_modules/quill/dist/quill.js"],
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.webmanifest"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "app:serve"
},
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "app"
}
Hi @bri1990,
You don't need to have webpack listed as dependency in your project. @angular-devkit/build-angular already has a dependency on Webpack.
Kindly try the following;
npm uninstall webpackrm -rf node_modules package-lock.jsonnpm i
If the problem persist after doing the above steps please provide the output of npm ls webpack
Hi @alan-agius4
This resolved our problem! thank you!
We were under the impression that it was required, perhaps a left over dependancy from the past?
I ran into the same issue while upgrading. My issue was that storybook is still using webpack 4 and was holding onto the old version. After following the guide at https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#upgrade, and deleting my node_modules and package lock, I was able to install and run the app successfully.
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.