简体   繁体   English

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

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

I started to publish my Angular app.我开始发布我的 Angular 应用程序。 But I can't fix this error.但我无法修复这个错误。 I deployed in Azure.我部署在 Azure 中。 Add this looking easy.添加这个看起来很容易。 I think that the problem is in angular.json .我认为问题出在angular.json Firstly I tried to update every dependency in package.json首先,我尝试更新package.json每个依赖项

Where is the wrong in this config file?这个配置文件哪里错了?

    {
  "$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"
}

I tried to fix this, but when I execute npm build --prod ... I changed every dependency in my project, but didn't help.我试图解决这个问题,但是当我执行npm build --prod ......我改变了我项目中的每个依赖项,但没有帮助。 If someone is fixing this error.如果有人正在修复此错误。 Bro, pleas help!兄弟,求帮助! Thanks!谢谢!

I had a similar error when I ran the build command as below:当我运行构建命令时,我遇到了类似的错误,如下所示:

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

In Jenkins:在詹金斯:

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

In log file:在日志文件中:

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

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

I believe below are two reasons causing the issue in the angular.json file.我相信以下是导致 angular.json 文件中出现问题的两个原因。

  1. JSON is case sensitive so use both field names the same. JSON 区分大小写,因此使用相同的两个字段名称。
  2. angular.json missing the configuration for DEV. angular.json 缺少 DEV 的配置。

Check if you are missing the configuration for DEV, add something similar below.检查您是否缺少 DEV 的配置,在下面添加类似的内容。

code sample:代码示例:

"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.

相关问题 发生未处理的异常:工作区中未设置配置“es” - An unhandled exception occurred: Configuration 'es' is not set in the workspace 发生未处理的异常:工作区中未设置配置“生产” - An unhandled exception occurred: Configuration 'production' is not set in the workspace Angular ng 服务导致:发生未处理的异常:未在工作区中设置配置“生产” - Angular ng serve leads to: An unhandled exception occurred: Configuration 'production' is not set in the workspace 发生未处理的异常:在工作空间中未设置配置'es5'。 ng在角度8中投放es5 - An unhandled exception occurred: Configuration 'es5' is not set in the workspace. ng serve in angular 8 for es5 发生未处理的异常:D:\workspace-angular\demoapp1 包含 both.browserslistrc 和 browserslist - An unhandled exception occurred: D:\workspace-angular\demoapp1 contains both .browserslistrc and browserslist 发生未处理的异常:找不到 builder @angular-devkit/build-angular:dev-server 的实现 - An unhandled exception occurred: Could not find the implementation for builder @angular-devkit/build-angular:dev-server 发生未处理的异常:NGCC 失败 - An unhandled exception occurred: NGCC failed Angular 配置未设置到工作区 - Angular configuration not set to the workspace Angular - 工作区中未设置配置 - Angular - Configuration is not set in the workspace 运行 ng serve 发生未处理的异常 - Unhandled exception occurred running ng serve
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM