发生未处理的异常:在工作空间中未设置配置“生产" [英] An unhandled exception occurred: Configuration 'production' is not set in the workspace

查看:110
本文介绍了发生未处理的异常:在工作空间中未设置配置“生产"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi在Angular 8中创建了一个项目.最初,它仅支持一种默认语言(US-EN).然后我应用了本地化.

Hi Created one project in Angular 8. Initially it was supporting only one default language (US-EN). then I applied localization.

在本地化准备生产版本之前,我曾经给出以下命令.

before localization for preparing production build, I used to give following command.

ng build --prod --base-href "/Windchill/com/qiwkCollaborator/"

本地化后,我对angular.json和package.json进行了一些更改.在进行这些更改后,每当我发出任何命令来进行构建时,都会出现以下错误.

after localization, I made some changes in the angular.json and in package.json. after making these changes whenever I am giving any command to prepare to build it is giving me the following error.

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

Package.json文件的某些部分如下:

some portion of Package.json file is as follows:

"name": "qwik-collaborator",
  "version": "1.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build-locale:en": "ng build --prod --i18n-locale en --i18n-format xlf --i18n-file src/translate/messages.en.xlf --output-path=dist/en --baseHref /en/",
    "build-locale:fr": "ng build --prod --i18n-locale fr --i18n-format xlf --i18n-file src/translate/messages.fr.xlf --output-path=dist/fr --baseHref /fr/"

Angular.json文件的某些部分如下.

some portion of Angular.json file is as follows.

"build": {

          "configurations": {
            "fr": {
            "aot": true,
            "outputPath": "dist/qwikCollaborator/fr/",
            "i18nFile": "src/translate/messages.fr.xlf",      
            "i18nFormat": "xlf",      
            "i18nLocale": "fr",      
            "i18nMissingTranslation": "error"    
             },
             "en": {
            "aot": true,
            "outputPath": "dist/qwikCollaborator/en/",
            "i18nFile": "src/translate/messages.en.xlf",      
            "i18nFormat": "xlf",      
            "i18nLocale": "en",      
            "i18nMissingTranslation": "error"    
             }  
           },
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/qwikCollaborator",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": false,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss",
              "src/assets/css/custom-mobile.css",
              "src/assets/css/custom.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/js/qwikCollaborator.js"
            ]
          },
          "configurations": {
          "es5": {
        "tsConfig": "./tsconfig.es5.json"
      },
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
.......


"serve": {
           "configurations": {
            "fr": {
            "browserTarget": "qwikCollaborator:build:fr" 
            },
            "en": {
            "browserTarget": "qwikCollaborator:build:en" 
            } ,
            },
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "qwikCollaborator:build"
          },

          "configurations": {
          "es5": {
        "browserTarget": "qwikCollaborator:build:es5"
      },
            "production": {
              "browserTarget": "qwikCollaborator:build:es5"
            }
          }
        },

有人可以帮我吗?

推荐答案

您正在使用-prod 进行构建,这意味着将使用 production 配置,删除

You are building with --prod, which means to use the production configuration, which you obviously removed

您需要将构建脚本更改为

You need to change your build scripts to

"build-locale:en": "ng build -c en --output-path=dist/en --baseHref /en/",
"build-locale:fr": "ng build -c fr --output-path=dist/fr --baseHref /fr/"

angular.json 中指定的选项(如文件i18n文件格式和位置)无需在构建命令中再次指定

Options that are specified in angular.json (like file i18n file format and locations) do not need to be specified again in the build command

如果您要像以前一样使用 ng build --prod 进行构建,则只需将 production 配置添加回 build 目标

If you want to build using ng build --prod as before, you just need to add the production configuration back into the build target

这篇关于发生未处理的异常:在工作空间中未设置配置“生产"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆