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

11,939

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

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

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

Share:
11,939
Jayesh Vyas
Author by

Jayesh Vyas

Freelancer | PLM Developer | Java Developer | Competitive Coder | FrontEnd Programmer | Team Player Optimistic guy, who loves to code. always ready to learn any new things which add as a plus and valuable point in my skills. Started working with PHP, JavaScript, Html & CSS. currently working on JAVA(Spring and Hibernate), MySQL, Angular, JavaScript, Android, and PLM related tools. Creative by nature, passionate about coding, core skills lie in designing and coding. Currently learning Python(Intermediate), AI and machine learning. Apart from my professional and technical skills, I am a foodie, a cook, and a photographer. I love traveling and want to explore the places as much as I can.

Updated on June 18, 2022

Comments

  • Jayesh Vyas
    Jayesh Vyas almost 2 years

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

    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.
    

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

    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"
                }
              }
            },
    

    can anyone help me with this?