不能 运行 ng 在开发模式下服务

can't run ng serve in development mode

我不能 运行 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'
};

我 Chrome 的 Angular 扩展警告我,我正在 运行 生产中,即使我不想:

We detected an application built with production configuration. Angular DevTools only supports development builds.

ng 在 angular.json

上投放部分
"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.