PS F:\WorkGitHub\angulard3tree> ng serve
⠋ Generating browser application bundles (phase: setup)...An unhandled exception occurred: webpack_1.AngularWebpackPlugin is not a constructor
See "C:\Users\ghosii\AppData\Local\Temp\ng-daZXzA\angular-errors.log" for further details.
⠦ Generating browser application bundles (phase: setup)...
chatGPT也没有解决到
如果你的Angular版本是12及以上,但是在编译过程中遇到了 webpack_1.AngularWebpackPlugin is not a constructor
错误,可以尝试以下解决方法:
-
升级
sql@angular-devkit/build-angular
到最新版本。可以运行以下命令更新:ng update @angular-devkit/build-angular
-
确认
jsontsconfig.json
中的angularCompilerOptions
选项被正确配置。可以参考以下配置:"angularCompilerOptions": { "enableIvy": true, "tsConfig": "./tsconfig.app.json" }
-
检查是否已经安装了
sql@ngtools/webpack
。如果没有安装可以运行以下命令安装:npm install @ngtools/webpack --save-dev