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
错误,可以尝试以下解决方法:
- 升级
@angular-devkit/build-angular
到最新版本。可以运行以下命令更新:
sqlCopy code
ng update @angular-devkit/build-angular
- 确认
tsconfig.json
中的angularCompilerOptions
选项被正确配置。可以参考以下配置:
jsonCopy code
"angularCompilerOptions": { "enableIvy": true, "tsConfig": "./tsconfig.app.json" }
- 检查是否已经安装了
@ngtools/webpack
。如果没有安装可以运行以下命令安装:
sqlCopy code
npm install @ngtools/webpack --save-dev
- 如果问题仍然存在,请尝试卸载并重新安装@angular-devkit/build-angular和@angular/cli,然后执行npm install或yarn install更新依赖项。