繁体   English   中英

发生未处理的异常:工作区中未设置配置“dev”

[英]An unhandled exception occurred: Configuration 'dev' is not set in the workspace

我开始发布我的 Angular 应用程序。 但我无法修复这个错误。 我部署在 Azure 中。 添加这个看起来很容易。 我认为问题出在angular.json 首先,我尝试更新package.json每个依赖项

这个配置文件哪里错了?

    {
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ODZ.Web": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "progress": false,
            "extractCss": false,
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/assets"
            ],
            "styles": [
              "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/solid.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/regular.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/brands.scss",
              "node_modules/angular-bootstrap-md/assets/scss/bootstrap/bootstrap.scss",
              "node_modules/angular-bootstrap-md/assets/scss/mdb.scss",
              "node_modules/animate.css/animate.css",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/chart.js/dist/Chart.js",
              "node_modules/hammerjs/hammer.min.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "ODZ.Web:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "ODZ.Web:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "ODZ.Web: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": [
              "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
              "src/styles.css"
            ],
            "scripts": [],
            "assets": [
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "server": {
          "builder": "@angular-devkit/build-angular:server",
          "options": {
            "outputPath": "dist-server",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.server.json"
          }
        }
      }
    },
    "ODZ.Web-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "ODZ.Web:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          },
          "configurations": {
            "production": {
              "devServerTarget": "ODZ.Web:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "ODZ.Web"
}

我试图解决这个问题,但是当我执行npm build --prod ......我改变了我项目中的每个依赖项,但没有帮助。 如果有人正在修复此错误。 兄弟,求帮助! 谢谢!

当我运行构建命令时,我遇到了类似的错误,如下所示:

ng build --configuration=DEV --crossOrigin=anonymous 

在詹金斯:

An unhandled exception occurred: Configuration 'DEV' is not set in the workspace.

在日志文件中:

Log filename: /tmp/ng-W1hy24/angular-errors.log 

[error] Error: Configuration 'DEV' is not set in the workspace.

我相信以下是导致 angular.json 文件中出现问题的两个原因。

  1. JSON 区分大小写,因此使用相同的两个字段名称。
  2. angular.json 缺少 DEV 的配置。

检查您是否缺少 DEV 的配置,在下面添加类似的内容。

代码示例:

"DEV": {

             "fileReplacements": [

               {

                 "replace": "src/environments/environment.ts",

                 "with": "src/environments/environment.dev.ts"

               }

             ],

             "optimization": true,

             "outputHashing": "all",

             "sourceMap": false,

             "extractCss": true,

             "namedChunks": false,

             "aot": true,

             "extractLicenses": true,

             "vendorChunk": false,

             "buildOptimizer": true,

             "budgets": [

               {

                 "type": "initial",

                 "maximumWarning": "4mb",

                 "maximumError": "6mb"

               }

             ],

             "serviceWorker": true,

             "ngswConfigPath": "ngsw-config.json"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM