我尝试使用我的特定配置为我的Angular应用程序提供服务,但Angular无法识别它:
$ 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.我的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完美工作
发布于 2019-11-15 20:17:24
您收到的错误是因为您没有将其添加到您的serve browserTarget配置中:
"serve":{
"fr": {
"browserTarget": "custom-reports:build:fr"
},
}发布于 2021-04-26 23:47:35
在Angular 11中,您需要将browserTarget属性放在configurations中(在angular.json文件中的serve下):
"serve": {
"configurations": {
"fr": {
"browserTarget": "custom-reports:build:fr"
},
},
},发布于 2021-10-08 07:21:18
我也面临着同样的问题,
An unhandled exception occurred: Configuration 'fr' is not set in the workspace.
See "/tmp/ng-nyZPjp/angular-errors.log" for further details.即使我在serve和build中设置了配置。
我的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/"
},
.
.
.
.
.
.
.
.
"serve": {
"configurations": {
"en": {
"browserTarget": "custom-reports:build:en"
},
"fr": {
"browserTarget": "custom-reports:build:fr"
}
},
},我还是有问题。
我通过改变配置的顺序解决了这个问题,这个问题就解决了。
更改后的angular.json
"configurations": {
"en": {
"aot": true,
"outputPath": "dist/en/",
"i18nFile": "src/i18n/messages.en.xlf",
"i18nFormat": "xlf",
"i18nLocale": "en",
"i18nMissingTranslation": "error",
"baseHref": "/en/"
},
"fr": {
"aot": true,
"outputPath": "dist/fr/",
"i18nFile": "src/i18n/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error",
"baseHref": "/fr/"
},
.
.
.
.
.
.
.
.
"serve": {
"configurations": {
"en": {
"browserTarget": "custom-reports:build:en"
},
"fr": {
"browserTarget": "custom-reports:build:fr"
}
},
},这对我很有效。
https://stackoverflow.com/questions/58876170
复制相似问题