[英]Angular ng serve leads to: An unhandled exception occurred: Configuration 'production' is not set in the workspace
I try to serve an angular (9.1.12) application with ng serve --configuration=production
local to test the application in production mode.我尝试使用
ng serve --configuration=production
local 为 angular (9.1.12) 应用程序提供服务,以在生产模式下测试应用程序。 I receive the error: Angular ng serve leads to An unhandled exception occurred: Configuration 'production' is not set in the workspace.
我收到错误:
Angular ng serve leads to An unhandled exception occurred: Configuration 'production' is not set in the workspace.
Any ideas what the issue might be?任何想法可能是什么问题?
My angular.json我的 angular.json
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"port": 4300,
"browserTarget": "employee-platform:build"
},
"configurations": {
"production": {
"browserTarget": "employee-platform:build:production"
}
}
},
similar to the "serve" please check in the "build" object and check for "configuration" some thing like below,类似于“服务”,请检查“构建”object 并检查“配置”,如下所示,
"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,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
where in the src/environments/environment.prod.ts file,在 src/environments/environment.prod.ts 文件中,
we have to set production to true我们必须将生产设置为真
export const environment = {
production: true
};
It looks like you are missing a configuration section under build
object:看起来您缺少
build
object 下的配置部分:
"build": {
...
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
...
}
}
},
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.