Search code examples
angularangular-cli

Angular - Configuration is not set in the workspace


I try to serve my Angular app with my specific configuration but Angular does not recognize it :

$ ng serve --configuration=fr
An unhandled exception occurred: Configuration 'fr' is not set in the workspace.
See "/tmp/ng-nyZPjp/angular-errors.log" for further details.

My angular.json :

"configurations": {
  "fr": {
    "aot": true,
    "outputPath": "dist/fr/",
    "i18nFile": "src/i18n/messages.fr.xlf",
    "i18nFormat": "xlf",
    "i18nLocale": "fr",
    "i18nMissingTranslation": "error",
    "baseHref": "/fr/"
  },
  "en": { 
    "aot": true,
    "outputPath": "dist/en/",
    "i18nFile": "src/i18n/messages.en.xlf",
    "i18nFormat": "xlf",
    "i18nLocale": "en",
    "i18nMissingTranslation": "error",
    "baseHref": "/en/"
  },
    ...

ng serve --configuration=en works perfectly


Solution

  • The error you are getting is because you didn't add it to your serve browserTarget configuration:

    "serve":{
       "fr": {
                "browserTarget": "custom-reports:build:fr"
             },
     }
    

    You may need to delete .angular to make the new environment visible.