gpt4 book ai didi

javascript - 无法在开发模式下运行 ng serve

转载 作者:行者123 更新时间:2023-12-04 11:50:10 25 4
gpt4 key购买 nike

我无法运行 ng serve处于开发模式。
我已将 Angular v11 升级到 v12。从那以后,我一直在编译延迟,并且似乎没有启用开发模式。
我总是收到这个警告:

****************************************************************************************
This is a simple server for use in testing or debugging Angular applications locally.
It hasn't been reviewed for security issues.

DON'T USE IT FOR PRODUCTION!
****************************************************************************************
我的 Lazy Chunk 文件是这样的:
Terminal
由于正在浏览器上设置编译文件,因此需要花费大量时间来调试任何内容。
Browser Inspect
我已经检查了我的 enviroment.ts 变量并设置为:
export const environment = {
production: false,
api: 'http://127.0.0.1:8000'
};
我的 Angular Extension for Chrome 警告我正在生产中运行,即使我不想:
We detected an application built with production configuration. Angular DevTools only supports development builds.
angular.json 上的 ng 服务部分
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "backoffice:build"
},
"configurations": {
"production": {
"browserTarget": "backoffice:build:production"
}
}
}
和 v11 上的完全一样,我已经检查过了
更新:
迁移问题。
已运行 ng update @angular/cli --migrate-only --from=11.2.0像@BojanKojog 一样回答下面的问题。

最佳答案

重新运行更新迁移

ng update @angular/cli --migrate-only --from=11.2.0
Explanation

Projects that have not used ng update to update to v12 are missing important migrations that switch some builder options to their default values in v11. Without this migration, the builder now assumes production configuration as the defaults were changed to represent production builds by default. An automatic migration that is run in ng update @angular/cli would set the affected options to their prior defaults, such that a project continues to behave the same. Without this migration however, builds are configured for production with the corresponding optimisations turned on, making development builds very slow.

Please use ng update @angular/cli --migrate-only --from=11.2.0 to apply the migrations or update using ng update @angular/core @angular/cli when still on v11.

关于javascript - 无法在开发模式下运行 ng serve,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68020083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com