Angular-cli: ng xi18n: Configuration 'xx' could not be found in project 'YYY'

Created on 13 Aug 2018  路  3Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [x] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

C:\Personal_Data\Web-Client>node --version
v10.1.0

C:\Personal_Data\Web-Client>npm --version
npm WARN npm npm does not support Node.js v10.1.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
5.6.0

C:\Personal_Data\Web-Client>ng --version

Angular CLI: 6.1.3
Node: 10.1.0
OS: win32 x64
Angular: 6.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.3
@angular-devkit/build-angular     0.7.3
@angular-devkit/build-optimizer   0.7.3
@angular-devkit/build-webpack     0.7.3
@angular-devkit/core              0.7.3
@angular-devkit/schematics        0.7.3
@angular/cdk                      6.4.3
@angular/cli                      6.1.3
@angular/flex-layout              6.0.0-beta.17
@angular/material                 6.4.3
@ngtools/webpack                  6.1.3
@schematics/angular               0.7.3
@schematics/update                0.7.3
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2

Repro steps

With the following file:

angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "rubywebclient": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "rbwc",
      "schematics": {
        "@schematics/angular:component": {
          "prefix": "rbwc",
          "styleext": "css"
        },
        "@schematics/angular:directive": {
          "prefix": "rbwc"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/rubywebclient",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/font-awesome/css/font-awesome.min.css",
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            },
            "fr": {
              "aot": true,
              "outputPath": "dist/rubywebclient-fr/",
              "i18nFile": "src/locale/messages.fr.xlf",
              "i18nFormat": "xlf",
              "i18nLocale": "fr"
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "rubywebclient:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "rubywebclient:build:production"
            },
            "fr": {
              "browserTarget": "rubywebclient:build:fr"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "rubywebclient: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/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/font-awesome/css/font-awesome.min.css",
              "src/styles.css"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "codeCoverage": true
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "rubywebclient-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "rubywebclient:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "rubywebclient:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "rubywebclient"
}

Execute the following instruction: ng xi18n --configuration=fr --output-path locale/ --out-file messages.fr.untranslated.xlf

The log given by the failure

C:\Personal_Data\Web-Client>ng xi18n --configuration=fr --output-path locale/ --out-file messages.fr.untranslated.xlf
Configuration 'fr' could not be found in project 'rubywebclient'.
Error: Configuration 'fr' could not be found in project 'rubywebclient'.
    at Architect.getBuilderConfiguration (C:\Personal_Data\Web-Client\node_modules\@angular-devkit\architect\src\architect.js:102:23)
    at MergeMapSubscriber._loadWorkspaceAndArchitect.pipe.operators_1.concatMap [as project] (C:\Personal_Data\Web-Client\node_modules\@angular\cli\models\architect-command.js:72:55)
    at MergeMapSubscriber._tryNext (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\operators\mergeMap.js:65:27)
    at MergeMapSubscriber._next (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\operators\mergeMap.js:55:18)
    at MergeMapSubscriber.Subscriber.next (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\Subscriber.js:64:18)
    at TapSubscriber._next (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\operators\tap.js:62:26)
    at TapSubscriber.Subscriber.next (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\Subscriber.js:64:18)
    at MergeMapSubscriber.notifyNext (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\operators\mergeMap.js:84:26)
    at InnerSubscriber._next (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\InnerSubscriber.js:25:21)
    at InnerSubscriber.Subscriber.next (C:\Personal_Data\Web-Client\node_modules\rxjs\internal\Subscriber.js:64:18)

Mention any other details that might be useful

devkibuild-angular

Most helpful comment

When you run ng xi18n --configuration=fr, the target that actually runs is this one:

        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "rubywebclient:build"
          }
        },

There you indeed have no configuration named fr. You can add it there and save the options you want to use:

        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "rubywebclient:build"
          },
          "configurations" : {
            "fr": {
              "outputPath": "locale/",
              "outFile": "messages.fr.untranslated.xlf",
              "i18nFormat": "xlf",
              "i18nLocale": "fr"
            }
          }
        },

Then running ng xi18n --configuration=fr will use those options.

All 3 comments

When you run ng xi18n --configuration=fr, the target that actually runs is this one:

        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "rubywebclient:build"
          }
        },

There you indeed have no configuration named fr. You can add it there and save the options you want to use:

        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "rubywebclient:build"
          },
          "configurations" : {
            "fr": {
              "outputPath": "locale/",
              "outFile": "messages.fr.untranslated.xlf",
              "i18nFormat": "xlf",
              "i18nLocale": "fr"
            }
          }
        },

Then running ng xi18n --configuration=fr will use those options.

@filipesilva Thank you very much for your answer...I though that the target was the configurations in the "architect {build{configurations}}}" part... But it makes a lot of sense that it should comes from "extract-i18n"... Sorry for the inconvenience

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings